A ridiculously large commit as a checkpoint in refactoring the time_t + an int
authorrobertlipe <robertlipe@f51c46e8-681c-474f-0cfe-069cfd0219fb>
Mon, 17 Jun 2013 02:07:08 +0000 (02:07 +0000)
committerrobertlipe <robertlipe@f51c46e8-681c-474f-0cfe-069cfd0219fb>
Mon, 17 Jun 2013 02:07:08 +0000 (02:07 +0000)
for microseconds into a QDateTime to give us sensible interface to time
beyond 1970 and 2032 and, more topically, more unified handling of sub-second
time now that 10Hz GPSes aren't uncommon.

This gets almost all of the accesses to wpt->creation_time into accessors
(with overloads for int/time_t and QDateTime) and eliminates many of
the problematic direct accesses to wpt->microseconds.

git-svn-id: http://gpsbabel.googlecode.com/svn/trunk@4398 f51c46e8-681c-474f-0cfe-069cfd0219fb

86 files changed:
gpsbabel/GPSBabel.xcodeproj/project.xcworkspace/xcuserdata/robertlipe.xcuserdatad/UserInterfaceState.xcuserstate
gpsbabel/alan.cc
gpsbabel/an1.cc
gpsbabel/axim_gpb.cc
gpsbabel/brauniger_iq.cc
gpsbabel/cetus.cc
gpsbabel/coastexp.cc
gpsbabel/compegps.cc
gpsbabel/coto.cc
gpsbabel/cst.cc
gpsbabel/csv_util.cc
gpsbabel/defs.h
gpsbabel/delbin.cc
gpsbabel/delgpl.cc
gpsbabel/destinator.cc
gpsbabel/dg-100.cc
gpsbabel/exif.cc
gpsbabel/g7towin.cc
gpsbabel/garmin.cc
gpsbabel/garmin_device_xml.h
gpsbabel/garmin_txt.cc
gpsbabel/garmin_xt.cc
gpsbabel/gcdb.cc
gpsbabel/gdb.cc
gpsbabel/geoniche.cc
gpsbabel/ggv_log.cc
gpsbabel/glogbook.cc
gpsbabel/gnav_trl.cc
gpsbabel/gopal.cc
gpsbabel/gpilots.cc
gpsbabel/gpssim.cc
gpsbabel/gpsutil.cc
gpsbabel/gpx.cc
gpsbabel/gtm.cc
gpsbabel/gtrnctr.cc
gpsbabel/hiketech.cc
gpsbabel/holux.cc
gpsbabel/hsa_ndv.cc
gpsbabel/html.cc
gpsbabel/humminbird.cc
gpsbabel/igc.cc
gpsbabel/igo8.cc
gpsbabel/jtr.cc
gpsbabel/kml.cc
gpsbabel/magproto.cc
gpsbabel/mapsend.cc
gpsbabel/mapsource.cc
gpsbabel/mmo.cc
gpsbabel/mtk_locus.cc
gpsbabel/navicache.cc
gpsbabel/navilink.cc
gpsbabel/nmea.cc
gpsbabel/osm.cc
gpsbabel/ozi.cc
gpsbabel/palmdoc.cc
gpsbabel/pathaway.cc
gpsbabel/pcx.cc
gpsbabel/pocketfms_bc.cc
gpsbabel/psitrex.cc
gpsbabel/raymarine.cc
gpsbabel/route.cc
gpsbabel/saroute.cc
gpsbabel/sbn.cc
gpsbabel/skyforce.cc
gpsbabel/skytraq.cc
gpsbabel/smplrout.cc
gpsbabel/sort.cc
gpsbabel/src/core/datetime.h
gpsbabel/stmsdf.cc
gpsbabel/stmwpp.cc
gpsbabel/subrip.cc
gpsbabel/text.cc
gpsbabel/tiger.cc
gpsbabel/trackfilter.cc
gpsbabel/unicsv.cc
gpsbabel/v900.cc
gpsbabel/vitosmt.cc
gpsbabel/vitovtt.cc
gpsbabel/vpl.cc
gpsbabel/waypt.cc
gpsbabel/wbt-200.cc
gpsbabel/wfff_xml.cc
gpsbabel/wintec_tes.cc
gpsbabel/xmlgeneric.cc
gpsbabel/xmlgeneric.h
gpsbabel/xol.cc

index ca4bc1663d56f454e0912ad9b1c75b6a87657f57..f504b6e2d70cb1619d3d9564a1e21cc99f361092 100644 (file)
Binary files a/gpsbabel/GPSBabel.xcodeproj/project.xcworkspace/xcuserdata/robertlipe.xcuserdatad/UserInterfaceState.xcuserstate and b/gpsbabel/GPSBabel.xcodeproj/project.xcworkspace/xcuserdata/robertlipe.xcuserdatad/UserInterfaceState.xcuserstate differ
index d855fd66e41cfe886ff84bbe09fe0305904b7bde..c7a0c6b2ef6a0b4f9b2b8bce2e50cee39666246f 100644 (file)
@@ -505,7 +505,7 @@ static waypoint* get_wpt(struct wprdata* wprdata, unsigned n)
   WP = waypt_new();
   WP->latitude  = -pt2deg(wpt->pt.y);
   WP->longitude =  pt2deg(wpt->pt.x);
-  WP->creation_time = unpack_time(wpt->date, wpt->time);
+  WP->SetCreationTime(unpack_time(wpt->date, wpt->time));
   for (j=WPT_NAME_LEN-1; j >= 0 && wpt->name[j] == ' '; j--) {};
   WP->shortname = xstrndup(wpt->name,j+1);
   for (j=WPT_COMMENT_LEN-1; j >= 0 && wpt->comment[j] == ' '; j--) {};
@@ -706,7 +706,7 @@ static int add_wpt(struct wprdata* wprdata, const waypoint* WP,int isroute)
   wpt->usecount = isroute ? 1 : 0;
   wpt->checked  = isroute ? 0 : 1;
   wpt->reserved = 0;
-  pack_time(WP->creation_time, &(wpt->date), &(wpt->time));
+  pack_time(WP->GetCreationTime(), &(wpt->date), &(wpt->time));
 
   wpthdr->idx[hdr_idx] = wpt_idx;
   wpthdr->used[wpt_idx] = WPT_USED;
index 480f29a413fd35e36938db36a2325eb9db24989e..63ca40309f95b6359ceccf274e0be4cab41a5864 100644 (file)
@@ -703,7 +703,7 @@ static void Read_AN1_Waypoints(gbfile* f)
     wpt_tmp = waypt_new();
 
     if (rec->creation_time) {
-      wpt_tmp->creation_time = rec->creation_time;
+      wpt_tmp->SetCreationTime(rec->creation_time);
     }
     wpt_tmp->longitude = -DecodeOrd(rec->lon);
     wpt_tmp->latitude = DecodeOrd(rec->lat);
@@ -795,7 +795,7 @@ Write_One_AN1_Waypoint(const waypoint* wpt)
   }
 
 
-  rec->creation_time = rec->modification_time = wpt->creation_time;
+  rec->creation_time = rec->modification_time = wpt->GetCreationTime();
   rec->lat = EncodeOrd(wpt->latitude);
   rec->lon = EncodeOrd(-wpt->longitude);
   rec->serial = serial++;
index 424fc141db6cac2471c9be7d2ae306cc3d1d762c..3190576a35e1f77f8838fd4d39c913dfa353ec3b 100644 (file)
@@ -114,7 +114,7 @@ decode_buff(const char* buff, route_head* track)
 
   tm.tm_year-=1900;
   tm.tm_mon--;
-  wpt->creation_time = mkgmtime(&tm);
+  wpt->SetCreationTime(mkgmtime(&tm));
 
   track_add_wpt(track, wpt);
 }
index 30d0024b37452c586f6fc0affc0b2b4bd502416f..c0e725d9a559694971b7716f8eb6adf95f8d99ea 100644 (file)
@@ -202,7 +202,7 @@ static int process_data(const unsigned char* data)
   case st_sample_alt:
     wpt = waypt_new();
     wpt->latitude = wpt->longitude = 0.0;
-    wpt->creation_time = creation;
+    wpt->SetCreationTime(creation);
     creation += interval;
     wpt->altitude = (data[0] << 8) + data[1];
     track_add_wpt(track, wpt);
index 0e3925ca4e4be1952815b4d11650fb68615bbe4f..022d22cec47d57be8204d9654a7d68f8624da171 100644 (file)
@@ -455,12 +455,12 @@ cetus_writewpt(const waypoint* wpt)
 
   rec = (struct cetus_wpt_s*) xcalloc(sizeof(*rec)+18 + NOTESZ + DESCSZ,1);
 
-  QDate date(wpt->creation_time.date());
+  QDate date(wpt->GetCreationTime().date());
   rec->day = date.day();
   rec->mon = date.month();
   be_write16(&rec->year, date.year());
 
-  QTime time(wpt->creation_time.time());
+  QTime time(wpt->GetCreationTime().time());
   rec->min = time.minute();
   rec->hour = time.hour();
   rec->sec = time.second();
index 7aa72c74c285c5223fab30c755cdd21ed5f6abbe..030ca04ea345ab263df475c372df787912980f5b 100644 (file)
@@ -292,7 +292,7 @@ ce_cdata(void* dta, const XML_Char* xml_s, int len)
           strncpy(secString, currentMark->created+13, 2);
           secString[2] = '\0';
           t.tm_sec = atoi(secString);
-          currentMark->wp->creation_time = mkgmtime(&t);
+          currentMark->wp->SetCreationTime(mkgmtime(&t));
         }
       } else if (inRoute) {
         currentRoute->r->rte_name = xstrdup(s);
@@ -524,7 +524,7 @@ ce_wr_deinit(void)
 static char*
 ce_gen_creation_time(time_t tm)
 {
-  xml_fill_in_time(time_buffer, tm, 0, XML_SHORT_TIME);
+  xml_fill_in_time(time_buffer, tm, XML_SHORT_TIME);
   return time_buffer;
 }
 
@@ -660,7 +660,7 @@ ce_mark_pr(const waypoint* wp)
     id = xml_buffer;
   }
   write_xml_entity_begin2(ofd, "\t", "Mark",
-                          "created", ce_gen_creation_time(wp->creation_time),
+                          "created", ce_gen_creation_time(wp->GetCreationTime()),
                           "id", id);
   ce_waypt_pr(wp);
   write_xml_entity_end(ofd, "\t", "Mark");
index b078acbb7b55b6a04712a7c24ec5083c9eb4b5b9..9a8251b0b153304521ac3dace1a020ef1e470c62 100644 (file)
@@ -207,7 +207,7 @@ parse_wpt(char* buff)
       case 5:
         if (has_time) {
           compegps_parse_time(c, &tm);
-          wpt->creation_time = mkgmtime(&tm);
+          wpt->SetCreationTime(mkgmtime(&tm));
         }
       case 6:
         wpt->altitude = atof(c);
@@ -305,7 +305,7 @@ parse_trkpt(char* buff)
         break;
       case 5:
         compegps_parse_time(c, &tm);
-        wpt->creation_time = mkgmtime(&tm);
+        wpt->SetCreationTime(mkgmtime(&tm));
         break;
       case 7:
         wpt->altitude = atof(c);
@@ -562,7 +562,7 @@ write_trkpt_cb(const waypoint* wpt)
   buff[0] = '\0';
 
   if (wpt->creation_time != 0) {
-    const time_t tt = wpt->creation_time;
+    const time_t tt = wpt->GetCreationTime();
     struct tm tm = *gmtime(&tt);
 
     strftime(buff, sizeof(buff), "%d-%b-%y %H:%M:%S", &tm);
index adf5775f5bec57e009b5cf12f9135a455980dc5a..b2141badbee62040501db81597ef30baebc85a57 100644 (file)
@@ -243,7 +243,7 @@ coto_track_read(void)
     rec->time = be_read32(&rec->time);
     if (rec->time != 0) {
       rec->time -= 2082844800U;
-      wpt_tmp->creation_time = rec->time;
+      wpt_tmp->SetCreationTime(rec->time);
     }
     track_add_wpt(trk_head, wpt_tmp);
   }
index aca0cac02704904c3f0172d618130b98ba22eb33..f13f9c9e7cfd97d6c73c5d27def6e25810c58368 100644 (file)
@@ -292,7 +292,7 @@ cst_data_read(void)
           pow = lrtrim(++pow);
           strptime(pow, "%Y %m %d %H:%M:%S", &tm);
 
-          wpt->creation_time = mkgmtime(&tm);
+          wpt->SetCreationTime(mkgmtime(&tm));
         }
         wpt->latitude /= 100000.0;
         wpt->longitude /= 100000.0;
index 4af5ba618a0d1c9ff075b7eda126f93642b6a4a9..a13028360d2d94b1e23d32bfc6e75180bd7ac4ff 100644 (file)
@@ -1173,37 +1173,36 @@ xcsv_parse_val(const char* s, waypoint* wpt, const field_map_t* fmp,
     /* TIME CONVERSIONS ***************************************************/
   case XT_EXCEL_TIME:
     /* Time as Excel Time  */
-    wpt->creation_time = EXCEL_TO_TIMET(atof(s));
+    wpt->SetCreationTime(EXCEL_TO_TIMET(atof(s)));
     break;
   case XT_TIMET_TIME:
     /* Time as time_t */
-    wpt->creation_time = (time_t) atol(s);
+    wpt->SetCreationTime((time_t) atol(s));
     break;
   case XT_TIMET_TIME_MS: {
     /* Time as time_t in milliseconds */
     int s_len = strlen(s);
     if (s_len < 4) {
       /* less than 1 epochsecond, an unusual case */
-      wpt->creation_time = (time_t) 0;
-      wpt->microseconds = (int) atoi(s) * 1000;
+      wpt->SetCreationTime(0,(int) atoi(s) * 1000);
     } else {
       char buff[32];
       int off = s_len - 3;
       strncpy(buff, s, off);
       buff[off] = '\0';
-      wpt->creation_time = (time_t) atol(buff);
+      time_t t = (time_t) atol(buff);
       s += off;
       strncpy(buff, s, 3);
       buff[3] = '\0';
-      wpt->microseconds = (int) atoi(buff) * 1000;
+      wpt->SetCreationTime(t, (int) MILLI_TO_MICRO(atoi(buff)));
     }
   }
   break;
   case XT_YYYYMMDD_TIME:
-    wpt->creation_time = yyyymmdd_to_time(s);
+    wpt->SetCreationTime(yyyymmdd_to_time(s));
     break;
   case XT_GMT_TIME:
-    wpt->creation_time += sscanftime(s, fmp->printfc, 1);
+    wpt->SetCreationTime(sscanftime(s, fmp->printfc, 1));
     break;
   case XT_LOCAL_TIME:
     if (getenv("GPSBABEL_FREEZE_TIME")) {
@@ -1224,7 +1223,7 @@ xcsv_parse_val(const char* s, waypoint* wpt, const field_map_t* fmp,
     wpt->creation_time = xml_parse_time(s, &wpt->microseconds);
     break;
   case XT_NET_TIME: {
-    time_t tt = wpt->creation_time;
+    time_t tt = wpt->GetCreationTime();
     dotnet_time_to_time_t(atof(s), &tt, &wpt->microseconds);
     }
     break;
@@ -1937,43 +1936,42 @@ xcsv_waypt_pr(const waypoint* wpt)
       /* TIME CONVERSIONS**************************************************/
     case XT_EXCEL_TIME:
       /* creation time as an excel (double) time */
-      writebuff(buff, fmp->printfc, TIMET_TO_EXCEL(wpt->creation_time));
+      writebuff(buff, fmp->printfc, TIMET_TO_EXCEL(wpt->GetCreationTime()));
       break;
     case XT_TIMET_TIME:
       /* time as a time_t variable */ {
-      time_t tt = wpt->creation_time;
+      time_t tt = wpt->GetCreationTime();
       writebuff(buff, fmp->printfc, tt); }
       break;
     case XT_TIMET_TIME_MS: {
       /* time as a time_t variable in milliseconds */
       char tbuf[24];
-      writetime(tbuf, sizeof(tbuf), "%s", wpt->creation_time, 0);
+      writetime(tbuf, sizeof(tbuf), "%s", wpt->GetCreationTime(), 0);
       char mbuf[32];
       snprintf(mbuf, sizeof(mbuf), "%s%03d", tbuf, wpt->microseconds / 1000);
       writebuff(buff, "%s", mbuf);
     }
     break;
     case XT_YYYYMMDD_TIME:
-      writebuff(buff, fmp->printfc, time_to_yyyymmdd(wpt->creation_time));
+      writebuff(buff, fmp->printfc, time_to_yyyymmdd(wpt->GetCreationTime()));
       break;
     case XT_GMT_TIME:
-      writetime(buff, sizeof buff, fmp->printfc, wpt->creation_time, 1);
+      writetime(buff, sizeof buff, fmp->printfc, wpt->GetCreationTime(), 1);
       break;
     case XT_LOCAL_TIME:
-      writetime(buff, sizeof buff, fmp->printfc, wpt->creation_time, 0);
+      writetime(buff, sizeof buff, fmp->printfc, wpt->GetCreationTime(), 0);
       break;
     case XT_HMSG_TIME:
-      writehms(buff, sizeof buff, fmp->printfc, wpt->creation_time, 1);
+      writehms(buff, sizeof buff, fmp->printfc, wpt->GetCreationTime(), 1);
       break;
     case XT_HMSL_TIME:
-      writehms(buff, sizeof buff, fmp->printfc, wpt->creation_time, 0);
+      writehms(buff, sizeof buff, fmp->printfc, wpt->GetCreationTime(), 0);
       break;
     case XT_ISO_TIME:
-      writetime(buff, sizeof buff, "%Y-%m-%dT%H:%M:%SZ", wpt->creation_time, 1);
+      writetime(buff, sizeof buff, "%Y-%m-%dT%H:%M:%SZ", wpt->GetCreationTime(), 1);
       break;
     case XT_ISO_TIME_MS:
-      xml_fill_in_time(buff, wpt->creation_time,
-                       wpt->microseconds, XML_LONG_TIME);
+      xml_fill_in_time(buff, wpt->GetCreationTime(), XML_LONG_TIME);
       break;
     case XT_GEOCACHE_LAST_FOUND:
       writebuff(buff, fmp->printfc, time_to_yyyymmdd(wpt->gc_data->last_found));
index 77d0ef73fdc10eb7fce048ce198c02b42bcfde5c..7256c5ca9ed94820b19d73c8e91d5ca29d02c806 100644 (file)
@@ -467,6 +467,7 @@ public:
   session(NULL), 
   extra_data(NULL) { }
  public:
+  QString CreationTimeXML() const;
   queue Q;                     /* Master waypoint q.  Not for use
                                           by modules. */
 
@@ -524,6 +525,13 @@ public:
 
   wp_flags wpt_flags;
   QString icon_descr;
+
+  gpsbabel::DateTime  GetCreationTime() const { return creation_time; }
+  void SetCreationTime(time_t t) { creation_time = t; }
+  void SetCreationTime(time_t t, int us) {
+    creation_time = t; 
+    microseconds = us;
+  }
   gpsbabel::DateTime creation_time;
   int microseconds;    /* Optional millionths of a second. */
 
@@ -1009,7 +1017,7 @@ const char* get_filename(const char* fname);                      /* extract the filename portion *
 #define str_iso8859_1_to_utf8(str) cet_str_iso8859_1_to_utf8((str))
 
 /* this lives in gpx.c */
-time_t xml_parse_time(const char* cdatastr, int* microsecs);
+gpsbabel::DateTime xml_parse_time(const char* cdatastr, int* microsecs);
 
 xml_tag* xml_findfirst(xml_tag* root, const char* tagname);
 xml_tag* xml_findnext(xml_tag* root, xml_tag* cur, const char* tagname);
index aabd1a1de79db821f0d7a19ef5ffb3eafc6bada1..5fd44609adffb85025a45ef7266f9ee969440764 100644 (file)
@@ -998,7 +998,7 @@ decode_waypoint(const void* data)
   const char* s;
   float f;
 
-  wp->creation_time = decode_time(&p->year);
+  wp->SetCreationTime(decode_time(&p->year));
   wp->latitude = delbin_rad2deg(le_read32(p->latitude));
   wp->longitude = delbin_rad2deg(le_read32(p->longitude));
   f = le_read_float(p->elevation);
@@ -1414,7 +1414,7 @@ write_waypoint(const waypoint* wp)
   waypoint_i++;
   le_write32(p->total, waypoint_n);
   le_write32(p->index, waypoint_i);
-  encode_time(wp->creation_time, &p->year);
+  encode_time(wp->GetCreationTime(), &p->year);
   le_write32(p->latitude, delbin_deg2rad(wp->latitude));
   le_write32(p->longitude, delbin_deg2rad(wp->longitude));
   if (wp->altitude > unknown_alt) {
@@ -1529,7 +1529,7 @@ decode_track_point(const void* data, unsigned* wp_array_i, unsigned max_point)
     waypoint* wp = waypt_new();
     float elev = le_read_float(p->point[i].elevation);
     wp_array[j] = wp;
-    wp->creation_time = decode_time(&p->point[i].year);
+    wp->SetCreationTime(decode_time(&p->point[i].year));
     wp->latitude = delbin_rad2deg(le_read32(p->point[i].latitude));
     wp->longitude = delbin_rad2deg(le_read32(p->point[i].longitude));
     if (elev > UNKNOWN_ELEV) {
@@ -1713,7 +1713,7 @@ write_track_points(void)
       le_write32(p->index, i + 1);
     }
     assert(p);
-    encode_time(wp->creation_time, &p->point[j].year);
+    encode_time(wp->GetCreationTime(), &p->point[j].year);
     le_write32(p->point[j].latitude, delbin_deg2rad(wp->latitude));
     le_write32(p->point[j].longitude, delbin_deg2rad(wp->longitude));
     f = UNKNOWN_ELEV;
@@ -1793,7 +1793,7 @@ write_track_end(const route_head* track)
   if (track->rte_name) {
     strncpy(p->name, track->rte_name, sizeof(p->name) - 1);
   } else {
-    sprintf(p->name, "%lu", (long)wp_array[0]->creation_time);
+    sprintf(p->name, "%lu", (long)wp_array[0]->GetCreationTime());
   }
   le_write32(p->total_points, waypoint_n);
   encode_time(current_time(), &p->year);
@@ -2186,7 +2186,7 @@ write_route_end(const route_head* route)
   if (route->rte_name) {
     strncpy(p->name, route->rte_name, sizeof(p->name) - 1);
   } else {
-    sprintf(p->name, "%lu", (long)wp_array[0]->creation_time);
+    sprintf(p->name, "%lu", (long)wp_array[0]->GetCreationTime());
   }
   p->type = 0;
   le_write32(p->total_route_point, route_point_n);
@@ -2222,7 +2222,7 @@ decode_navmsg(const void* data)
   t.tm_hour = p->hour;
   t.tm_min = p->minute;
   t.tm_sec = p->second;
-  wp->creation_time = mkgmtime(&t);
+  wp->SetCreationTime(mkgmtime(&t));
   wp->sat = p->satellites;
   wp->latitude = le_read_double(p->latitude);
   wp->longitude = le_read_double(p->longitude);
index 29006c7ff722689a468765a46e3292458926c2f0..a51c1d870a3a68088b5b44cd37a1e78bd3ae0682 100644 (file)
@@ -71,7 +71,7 @@ gpl_read(void)
     if (wpt_tmp->altitude <= unknown_alt + 1) {
       wpt_tmp->altitude = unknown_alt;
     }
-    wpt_tmp->creation_time = le_read32(&gp.tm);
+    wpt_tmp->SetCreationTime(le_read32(&gp.tm));
 
     switch (le_read32(&gp.status)) {
     case 1:
@@ -154,7 +154,7 @@ gpl_trackpt(const waypoint* wpt)
   le_write_double(&gp.alt, alt_feet);
   le_write_double(&gp.speed, speed);
   le_write_double(&gp.heading, heading);
-  le_write32(&gp.tm, wpt->creation_time);
+  le_write32(&gp.tm, wpt->GetCreationTime());
 
   gbfwrite(&gp, sizeof(gp), 1, gplfile_out);
 }
index 1de34ea3defa4162b5aa6804a79e316165bbc582..f56a0887534e4f5c8fc43b47b5ee9ae01b15a134 100644 (file)
@@ -332,8 +332,8 @@ destinator_read_trk(void)
 
     snprintf(buff, sizeof(buff), "%06d%.f", date, time);
     strptime(buff, "%d%m%y%H%M%S", &tm);
-    wpt->creation_time = mkgmtime(&tm);
-    wpt->microseconds = ((int)time % 1000) * 1000;
+    wpt->SetCreationTime(mkgmtime(&tm),
+                         ((int)time % 1000) * 1000);
 
     if (wpt->fix > 0) {
       wpt->fix = (fix_type)(wpt->fix + 1);
@@ -438,7 +438,7 @@ destinator_trkpt_disp(const waypoint* wpt)
     struct tm tm;
     double time;
     int date;
-    const time_t ct = wpt->creation_time;
+    const time_t ct = wpt->GetCreationTime();
     tm = *gmtime(&ct);
     tm.tm_mon += 1;
     tm.tm_year -= 100;
index b64d4386862473165d6e0031648aad58e51586ec..b6ffbd9e78b4916b08dbc5cbc5b4f5562ad629a1 100644 (file)
@@ -282,7 +282,7 @@ process_gpsfile(gbuint8 data[], route_head** track)
     if (style >= 1) {
       bintime = be_read32(data + i +  8) & 0x7FFFFFFF;
       bindate = be_read32(data + i + 12);
-      wpt->creation_time = bintime2utc(bindate, bintime);
+      wpt->SetCreationTime(bintime2utc(bindate, bintime));
       /* The device presents the speed as a fixed-point number
        * with a scaling factor of 100, in km/h.
        * The waypoint struct wants the speed as a
index 5e906b01312855f665e6a40a07f8b808ae5c1d8c..73450a9d098737cd17c8dc6a3c94cd51a0f5dcb2 100644 (file)
@@ -1503,7 +1503,7 @@ exif_write(void)
       struct tm tm;
       char buf[32];
 
-      const time_t tt = wpt->creation_time;
+      const time_t tt = wpt->GetCreationTime();
       tm = *gmtime(&tt);
 
       tm.tm_year += 1900;
index b910d6146712499a2ab99fba1f9ad2e9db3590bd..cf48069af8809a748843f9b7c678bbcdae34d25d 100644 (file)
@@ -105,7 +105,7 @@ parse_line(char* buff, int index, const char* delimiter, waypoint* wpt)
       if (cerr == NULL) {
         fatal(MYNAME ": Unable to convert date (%s)!\n", cin);
       }
-      wpt->creation_time = mkgmtime(&tm);
+      wpt->SetCreationTime(mkgmtime(&tm));
       break;
 
     case WAYPT__OFS + 1:
@@ -317,7 +317,7 @@ parse_waypt(char* buff)
   if (cerr == NULL) {
     fatal(MYNAME ": Unable to convert date (%s)!\n", buff);
   }
-  wpt->creation_time = mkgmtime(&tm);
+  wpt->SetCreationTime(mkgmtime(&tm));
 
   /* go over time stamp */
   i = 5;
index c865171f64b3a374ad33a9575ab0987c07dd1f06..60eadbf6584f04489e63b5594468cf60c6c1c7a0 100644 (file)
@@ -345,7 +345,7 @@ waypt_read(void)
     wpt->longitude = gps_save_lon;
     wpt->shortname = xstrdup("Position");
     if (gps_save_time) {
-      wpt->creation_time = gps_save_time;
+      wpt->SetCreationTime(gps_save_time);
     }
     waypt_add(wpt);
     return;
@@ -390,7 +390,7 @@ waypt_read(void)
       wpt_tmp->altitude = way[i]->alt;
     }
     if (way[i]->time_populated) {
-      wpt_tmp->creation_time = way[i]->time;
+      wpt_tmp->SetCreationTime(way[i]->time);
     }
 #if SOON
     garmin_fs_garmin_after_read(way[i], wpt_tmp, gps_waypt_type);
@@ -418,7 +418,7 @@ unsigned int checkWayPointIsAtSplit(waypoint* wpt, GPS_PLap* laps, int nlaps)
     int i;
     for (i=(nlaps-1); i >= 0; i--) {
       GPS_PLap lap = laps[i];
-      time_t delta = lap->start_time - wpt->creation_time;
+      time_t delta = lap->start_time - wpt->GetCreationTime();
       if ((delta >= -1) && (delta <= 1)) {
         result = 1;
         break;
@@ -503,7 +503,7 @@ track_read(void)
     wpt->heartrate = array[i]->heartrate;
     wpt->cadence = array[i]->cadence;
     wpt->shortname = xstrdup(array[i]->trk_ident);
-    wpt->creation_time = array[i]->Time;
+    wpt->SetCreationTime(array[i]->Time);
     wpt->wpt_flags.is_split = checkWayPointIsAtSplit(wpt, laps,
                               nlaps);
     wpt->wpt_flags.new_trkseg = next_is_new_trkseg;
@@ -985,7 +985,7 @@ waypoint_prepare(void)
       tx_waylist[i]->alt = wpt->altitude;
     }
     if (wpt->creation_time) {
-      tx_waylist[i]->time = wpt->creation_time;
+      tx_waylist[i]->time = wpt->GetCreationTime();
       tx_waylist[i]->time_populated = 1;
     }
     if (category) {
index 1edd98dedcd97c888a35583c1566db997efbdb77..4ee325c6bd114e4b70a2d1ad07a4873f98860219 100644 (file)
@@ -1437,7 +1437,7 @@ gpx_write_common_position(const waypoint* waypointp, const char* indent)
               indent, waypointp->altitude);
   }
   if (waypointp->creation_time) {
-    xml_write_time(ofd, waypointp->creation_time, waypointp->microseconds, "time");
+    xml_write_time(ofd, waypointp->GetCreationTime(), waypointp->microseconds, "time");
   }
 }
 
index b66e6da4d9d07d40eb01a331d823e7728e45bc79..88500f68445fa184d50ec3fe8f93284ba12f3e79 100644 (file)
@@ -255,11 +255,11 @@ prework_wpt_cb(const waypoint* wpt)
   waypoint* prev = cur_info->prev_wpt;
 
   if (prev != NULL) {
-    cur_info->time += (wpt->creation_time - prev->creation_time);
+    cur_info->time += (wpt->GetCreationTime() - prev->GetCreationTime());
     cur_info->length += waypt_distance_ex(prev, wpt);
   } else {
     cur_info->first_wpt = (waypoint*)wpt;
-    cur_info->start = wpt->creation_time;
+    cur_info->start = wpt->GetCreationTime();
   }
   cur_info->prev_wpt = (waypoint*)wpt;
   cur_info->count++;
@@ -618,7 +618,7 @@ write_waypt(const waypoint* wpt)
   print_string("%s\t", GMSD_GET(state, ""));
   country = gt_get_icao_country(GMSD_GET(cc, ""));
   print_string("%s\t", (country != NULL) ? country : "");
-  print_date_and_time(wpt->creation_time, 0);
+  print_date_and_time(wpt->GetCreationTime(), 0);
   print_string("%s\t", wpt->hasLink() ? wpt->url : "");
   print_categories(GMSD_GET(category, 0));
 
@@ -719,7 +719,7 @@ track_disp_wpt_cb(const waypoint* wpt)
   gbfprintf(fout, "Trackpoint\t");
 
   print_position(wpt);
-  print_date_and_time(wpt->creation_time, 0);
+  print_date_and_time(wpt->GetCreationTime(), 0);
   if IS_VALID_ALT(wpt->altitude) {
     print_distance(wpt->altitude, 1, 0, 0);
   }
@@ -733,7 +733,7 @@ track_disp_wpt_cb(const waypoint* wpt)
   if (prev != NULL) {
     float temp;
     gbfprintf(fout, "\t");
-    delta = wpt->creation_time - prev->creation_time;
+    delta = wpt->GetCreationTime() - prev->GetCreationTime();
     temp = WAYPT_GET(wpt, temperature, -999);
     if (temp != -999) {
       print_temperature(temp);
index 38fedfa04f7f46364cd60479dfc23b32338a518e..6b07e95b433285026ad81fc4d7ba0fba2fef6546 100644 (file)
@@ -298,7 +298,7 @@ format_garmin_xt_proc_strk(void)
           wpt->latitude = PrevLat;     /* Degrees */
           wpt->longitude = PrevLon;    /* Degrees */
           wpt->altitude = PrevEle;                     /* Meters. */
-          wpt->creation_time = Time;           /* Unix Time adjusted to Garmin time */
+          wpt->SetCreationTime(Time);                  /* Unix Time adjusted to Garmin time */
 
           // add way point to the track
           track_add_wpt(tmp_track, wpt);
@@ -324,7 +324,7 @@ format_garmin_xt_proc_strk(void)
     wpt->latitude = PrevLat;   /* Degrees */
     wpt->longitude = PrevLon;  /* Degrees */
     wpt->altitude = PrevEle;                   /* Meters. */
-    wpt->creation_time = Time;                 /* Unix Time adjusted to Garmin time */
+    wpt->SetCreationTime(Time);                /* Unix Time adjusted to Garmin time */
 
     // add way point to the track
     track_add_wpt(tmp_track, wpt);
@@ -396,7 +396,7 @@ format_garmin_xt_proc_atrk(void)
     wpt->latitude = LatF*180/16777216; /* Degrees */
     wpt->longitude = LonF*360/16777216;        /* Degrees */
     wpt->altitude = AltF;                      /* Meters. */
-    wpt->creation_time = Tim;                  /* Unix Time adjusted to Garmin time */
+    wpt->SetCreationTime(Tim);                 /* Unix Time adjusted to Garmin time */
 
     track_add_wpt(track, wpt);
   }
index 76a744b06e9cb8c14de92993a3ded12945e37ea5..e24993e703db6b0657a3a37f7e2bad668e5a2765 100644 (file)
@@ -154,7 +154,7 @@ if (!strncmp("date", rec->dbfld[i].fldname,4)) {
 time_t tm;
 tm = be_read32(recdata) * 24 * 3600;
 tm -= EPOCH_1904;
-wpt->creation_time = tm;
+wpt->SetCreationTime(tm);
 warning("date %d\n", tm);
 }
 break;
@@ -266,7 +266,7 @@ gcdb_add_to_rec(rec, "terr", RECTYPE_TEXT, tbuf);
 * not the cache creation date.
 */
 if (wpt->creation_time) {
-gcdb_add_to_rec(rec, "date", RECTYPE_DATE, (void*) wpt->creation_time);
+gcdb_add_to_rec(rec, "date", RECTYPE_DATE, (void*) wpt->GetCreationTime());
 }
 #endif
 
index 3d679b826a33fce26739cf5c94b32f2d1bcc4532..b3508ff3bc37a489bb00609d8845c7c2da70a3e5 100644 (file)
@@ -1406,7 +1406,7 @@ write_waypoint(
 
   FWRITE_i16(GMSD_GET(category, gdb_category));
   FWRITE_DBL(WAYPT_GET(wpt, temperature, 0), 0);
-  FWRITE_TIME(wpt->creation_time);
+  FWRITE_TIME(wpt->GetCreationTime());
 
   /* VERSION DEPENDENT CODE */
   if (gdb_ver >= GDB_VER_3) {
@@ -1588,7 +1588,7 @@ write_track(const route_head* trk, const char* trk_name)
     FWRITE_LATLON(wpt->latitude);
     FWRITE_LATLON(wpt->longitude);
     FWRITE_DBL(wpt->altitude, unknown_alt);
-    FWRITE_TIME(wpt->creation_time);
+    FWRITE_TIME(wpt->GetCreationTime());
     d = WAYPT_GET(wpt, depth, unknown_alt);
     FWRITE_DBL(d, unknown_alt);
     d = WAYPT_GET(wpt, temperature, -99999);
index 482e76a14cae82a80e7081fc31c2b35c7c4dab72..e2d92d84415efbba400645cfa77d1f3f4746a8e3 100644 (file)
@@ -378,7 +378,7 @@ geoniche_read_asc(void)
     tm.tm_year -= 1900;
     sscanf(timestr, "%d:%d:%d", &tm.tm_hour, &tm.tm_min, &tm.tm_sec);
     if (tm.tm_year >= 1970) {
-      wpt->creation_time = mktime(&tm);
+      wpt->SetCreationTime(mktime(&tm));
     }
     xfree(datestr);
     xfree(timestr);
@@ -540,7 +540,7 @@ geoniche_read_bin(void)
 
     waypt->shortname = xstrdup(vdata + 63);
     waypt->altitude = altitude;
-    waypt->creation_time = mkgmtime(&created);
+    waypt->SetCreationTime(mkgmtime(&created));
 
     GPS_Math_DegMin_To_Deg(latdeg, lat, &waypt->latitude);
     GPS_Math_DegMin_To_Deg(londeg, lon, &waypt->longitude);
@@ -749,7 +749,7 @@ geoniche_writewpt(const waypoint* wpt)
     id = rec_ct;
   }
 
-  tx = (wpt->creation_time != 0) ? wpt->creation_time : gpsbabel_time;
+  tx = (wpt->GetCreationTime() != 0) ? wpt->GetCreationTime() : gpsbabel_time;
   if (tx == 0) {       /* maybe zero during testo (freezed time) */
     strcpy(datestr, "01/01/1904");     /* this seems to be the uninitialized date value for geoniche */
     strcpy(timestr, "00:00:00");
index 5994bb6c118d8abe57c6ba015ab6a07fa85166b4..c2a3572e8b819a25ee73083bc47eb06c479d1a41 100644 (file)
@@ -179,7 +179,7 @@ ggv_log_read(void)
       tm.tm_year -= 1900;
       if (tm.tm_mon > 0) {
         tm.tm_mon--;
-        wpt->creation_time = mkgmtime(&tm);
+        wpt->SetCreationTime(mkgmtime(&tm));
       }
     }
 
@@ -224,7 +224,7 @@ ggv_log_track_head_cb(const route_head* trk)
     lonsec = 60.0 * (lonmin - floor(lonmin));
 
     if (wpt->creation_time > 0) {
-      tm = *gmtime(&wpt->creation_time);
+      tm = *gmtime(&wpt->GetCreationTime());
       tm.tm_mon += 1;
       tm.tm_year += 1900;
     } else {
index b42b6abebdd3fd34a23b7e41afbf17aef6397c18..cbdd0773301a5efeca1807b3f48bb68f7d40a1a9 100644 (file)
@@ -96,7 +96,7 @@ glogbook_waypt_pr(const waypoint* wpt)
   }
   gbfprintf(ofd, "                </Position>\n");
   gbfprintf(ofd, "                ");
-  xml_write_time(ofd, wpt->creation_time, wpt->microseconds, "Time");
+  xml_write_time(ofd, wpt->GetCreationTime(), wpt->microseconds, "Time");
   gbfprintf(ofd, "            </Trackpoint>\n");
 }
 
@@ -147,7 +147,7 @@ void        gl_trk_pnt_e(const char* args, const char** unused)
 
 void   gl_trk_utc(const char* args, const char** unused)
 {
-  wpt_tmp->creation_time = xml_parse_time(args, &wpt_tmp->microseconds);
+  wpt_tmp->SetCreationTime(xml_parse_time(args, &wpt_tmp->microseconds));
 }
 
 void   gl_trk_lat(const char* args, const char** unused)
index dc5216dee922cb923fbae3763ad0467bea7afe84..e15e6422d1f08310f579170905a24eafbae1da43 100644 (file)
@@ -100,7 +100,7 @@ gnav_trl_read(void)
 
     wpt = waypt_new();
 
-    wpt->creation_time = le_read32(&rec.time);
+    wpt->SetCreationTime(le_read32(&rec.time));
     wpt->latitude = le_read_float(&rec.lat);
     wpt->longitude = le_read_float(&rec.lon);
     wpt->altitude = read_altitude(&rec.alt);
@@ -118,7 +118,7 @@ gnav_trl_write_trkpt(const waypoint* wpt)
 {
   gnav_trl_t rec;
 
-  le_write32(&rec.time, wpt->creation_time);
+  le_write32(&rec.time, wpt->GetCreationTime());
   le_write_float(&rec.lat, wpt->latitude);
   le_write_float(&rec.lon, wpt->longitude);
   if (wpt->altitude != unknown_alt) {
index 59e9cdfb18ab277fac3dda7b26bf6d4b8821bb09..10c3b323d5df8ccb4d7747b2cb5a025d4c01669a 100644 (file)
@@ -308,7 +308,7 @@ gopal_read(void)
     //calculate the speed to reach this waypoint from the last. This way I try to sort out invalid waypoints
     speed=0;
     if (lastwpt !=NULL) {
-      speed=3.6*radtometers(gcdist(RAD(lastwpt->latitude), RAD(lastwpt->longitude), RAD(wpt->latitude), RAD(wpt->longitude))) / abs(wpt->creation_time - lastwpt->creation_time);
+      speed=3.6*radtometers(gcdist(RAD(lastwpt->latitude), RAD(lastwpt->longitude), RAD(wpt->latitude), RAD(wpt->longitude))) / abs(wpt->creation_time - lastwpt->GetCreationTime());
       //printf("speed line %d %lf \n",line,speed);
     }
     /* Error handling: in the tracklog of my device sometimes "jump" waypoints ;-) */
@@ -366,7 +366,7 @@ gopal_write_waypt(const waypoint* wpt)
     }
   }
   //MSVC handles time_t as int64, gcc and mac only int32, so convert it:
-  timestamp=(unsigned long)wpt->creation_time;
+  timestamp=(unsigned long)wpt->GetCreationTime();
   gbfprintf(fout, "%lu, %s, %lf, %lf, %5.1lf, %8.5lf, %d, %lf, %d\n",timestamp,tbuffer,  wpt->longitude, wpt->latitude,wpt->altitude,
             wpt->speed,fix,wpt->hdop,wpt->sat);
 }
index 56938403e609719e0c9f41f321dbf587a270357e..4e732359a6669206e4c7a2764c9e8ca77a982180 100644 (file)
@@ -313,7 +313,7 @@ data_read(void)
            * Garmin/GPilotS count seconds from "UTC 12:00 AM December 31 1989".
            * gpsbabel counts seconds from "UTC 12:00 AM January 1 1970".
            */
-          wpt_tmp->creation_time = be_read32(&tp_cust->time) + 631065600;
+          wpt_tmp->SetCreationTime(be_read32(&tp_cust->time) + 631065600);
           fi.i = be_read32(&tp_cust->alt);
           wpt_tmp->altitude = fi.f;
           track_add_wpt(track_head, wpt_tmp);
index 79b4943e1c181e4015f60f1bfb9860215ddbcf43..abf9728e744b337fd68c6fef4fab931d19f2cac4 100644 (file)
@@ -126,7 +126,7 @@ gpssim_write_pt(const waypoint* wpt)
     int hms, ymd;
     struct tm* tm;
 
-    const time_t tt = wpt->creation_time;
+    const time_t tt = wpt->GetCreationTime();
     tm = gmtime(&tt);
     hms = tm->tm_hour * 10000 + tm->tm_min * 100 + tm->tm_sec;
     ymd = tm->tm_mday * 10000 + tm->tm_mon * 100 + tm->tm_year;
index b1c41445fb203bf2c8365a2dfc6b9f476b725cb3..7e8b621ce095b283f0f01e42b0653794391cf252 100644 (file)
@@ -114,7 +114,7 @@ data_read(void)
     wpt_tmp->altitude = alt;
     wpt_tmp->shortname = sn;
     wpt_tmp->description = xstrdup(desc);
-    wpt_tmp->creation_time = now;
+    wpt_tmp->SetCreationTime(now);
 
     if (latdir == 'S') {
       lat = -lat;
index 212aeca59d62e203d8a62636f15b7eb11aa38372..03fe746b51e566af9bdd4b248d37981ece1396b7 100644 (file)
@@ -31,6 +31,7 @@ static XML_Parser psr;
 #include <QtCore/QRegExp>
 //#include <QtCore/QTextCodec>
 #include <QtXml/QXmlStreamAttributes>
+#include <QtCore/QDebug>
 
 
 static xml_tag* cur_tag;
@@ -844,7 +845,7 @@ gs_get_container(geocache_container t)
   return "Unknown";
 }
 
-time_t
+gpsbabel::DateTime
 xml_parse_time(const char* cdatastr, int* microsecs)
 {
   int off_hr = 0;
@@ -909,7 +910,18 @@ xml_parse_time(const char* cdatastr, int* microsecs)
 
   xfree(timestr);
 
-  return rv;
+  // TOOD(robertlipe) - This really is a groady hack to shim in 
+  // the old interface (which had an explicit microsecs pointer argument
+  // as an optional output value) and the new form which uses QDateTime
+  // but, because of the above hackery, doesn't really work outside 1970
+  // 2038 but which we can't replace until Steven upgrades Qt.
+  // Baby steps.
+  QDateTime dt = QDateTime::fromTime_t(rv);
+  if (microsecs) {
+    dt = dt.addMSecs(*microsecs / 1000);
+// qDebug() << dt.toString("dd.MM.yyyy hh:mm:ss.zzz")  << " ZZZ " << *microsecs;
+  }
+  return dt;
 }
 
 static void
@@ -1131,7 +1143,7 @@ gpx_end(void* data, const XML_Char* xml_el)
   case tt_wpt_time:
   case tt_trk_trkseg_trkpt_time:
   case tt_rte_rtept_time:
-    wpt_tmp->creation_time = xml_parse_time(cdatastrp, &wpt_tmp->microseconds);
+    wpt_tmp->SetCreationTime(xml_parse_time(cdatastrp, &wpt_tmp->microseconds));
     break;
   case tt_wpt_cmt:
   case tt_rte_rtept_cmt:
@@ -1437,7 +1449,7 @@ fprint_xml_chain(xml_tag* tag, const waypoint* wpt)
           strcmp(tag->tagname, "groundspeak:cache") == 0) {
         char time_string[64];
         xml_fill_in_time(time_string, wpt->gc_data->exported,
-                         0, XML_LONG_TIME);
+                         XML_LONG_TIME);
         if (time_string[0]) {
           writer.writeTextElement("time", time_string);
         }
@@ -1569,15 +1581,8 @@ gpx_write_common_position(const waypoint* waypointp)
   if (waypointp->altitude != unknown_alt) {
     writer.writeTextElement("ele", QString::number(waypointp->altitude, 'f', 6));
   }
-  if (waypointp->creation_time) {
-    char time_string[64];
-    // FIXME: Eventually use creation_time.toString()
-    xml_fill_in_time(time_string, waypointp->creation_time,
-                     waypointp->microseconds, XML_LONG_TIME);
-    if (time_string[0]) {
-      writer.writeTextElement("time", time_string);
-    }
-  }
+  QString t = waypointp->CreationTimeXML();
+  writer.writeOptionalTextElement("time", t);
 }
 
 static void
@@ -1946,7 +1951,7 @@ gpx_write(void)
 
   now = current_time();
   char time_string[64];
-  xml_fill_in_time(time_string, now, 0, XML_LONG_TIME);
+  xml_fill_in_time(time_string, now, XML_LONG_TIME);
   if (time_string[0]) {
     writer.writeTextElement("time", time_string);
   }
index 46b14b7325a9722eda85e461fb432b331c93e0e9..830465f3bf3ff67ca4a9ef78dc1116c1361509f3 100644 (file)
@@ -740,7 +740,7 @@ static void write_waypt(const waypoint* wpt)
   fwrite_integer(file_out, icon_from_descr(wpt->icon_descr));
   fwrite_byte(file_out, 3);
   if (wpt->creation_time) {
-    fwrite_long(file_out, wpt->creation_time-EPOCH89DIFF);
+    fwrite_long(file_out, wpt->GetCreationTime()-EPOCH89DIFF);
   } else {
     fwrite_long(file_out, 0);
   }
@@ -763,7 +763,7 @@ static void write_trk_waypt(const waypoint* wpt)
 {
   fwrite_double(file_out, wpt->latitude);
   fwrite_double(file_out, wpt->longitude);
-  fwrite_long(file_out, wpt->creation_time-EPOCH89DIFF);
+  fwrite_long(file_out, wpt->GetCreationTime()-EPOCH89DIFF);
   fwrite_byte(file_out, start_new);
   if (wpt->altitude == unknown_alt) {
     fwrite_single(file_out, unknown_alt_gtm);
index e776aaa6f3833eace362213d83427ad257f80e33..57e4d8edabfb20dd8b87d4e3fa9a4b30d324d468 100644 (file)
@@ -261,18 +261,18 @@ static void
 gtc_study_lap(const waypoint* wpt)
 {
   if (wpt->creation_time && (gtc_least_time == 0)) {
-    gtc_least_time = wpt->creation_time;
+    gtc_least_time = wpt->GetCreationTime();
     gtc_start_lat = wpt->latitude;
     gtc_start_long = wpt->longitude;
   }
 
-  if (wpt->creation_time && (gtc_least_time > wpt->creation_time)) {
-    gtc_least_time =  wpt->creation_time;
+  if (wpt->creation_time && (gtc_least_time > wpt->GetCreationTime())) {
+    gtc_least_time =  wpt->GetCreationTime();
     gtc_start_lat = wpt->latitude;
     gtc_start_long = wpt->longitude;
   }
   if (wpt->creation_time > gtc_most_time)  {
-    gtc_most_time = wpt->creation_time;
+    gtc_most_time = wpt->GetCreationTime();
     gtc_end_lat = wpt->latitude;
     gtc_end_long = wpt->longitude;
   }
@@ -288,12 +288,10 @@ gtc_waypt_pr(const waypoint* wpt)
   }
 
   if (wpt->creation_time) {
-    char time_string[100];
-    xml_fill_in_time(time_string, wpt->creation_time, wpt->microseconds,
-                     XML_LONG_TIME);
-    if (time_string[0]) {
+    QString time_string = wpt->CreationTimeXML();
+    if (!time_string.isEmpty()) {
       gtc_write_xml(0, "<Time>%s</Time>\n",
-                    time_string);
+                    qPrintable(time_string));
     }
   }
   if (wpt->latitude && wpt->longitude) {
@@ -394,7 +392,7 @@ gtc_act_hdr(const route_head* rte)
   route_disp(rte, gtc_study_lap);
   if (gtc_least_time) {
     char time_string[100];
-    xml_fill_in_time(time_string, gtc_least_time, 0, XML_LONG_TIME);
+    xml_fill_in_time(time_string, gtc_least_time, XML_LONG_TIME);
     gtc_write_xml(0, "<Id>%s</Id>\n", time_string);
     gtc_write_xml(1, "<Lap StartTime=\"%s\">\n", time_string);
   } else {
index bab21cdc8c8b3dc67aadd00a015bc3509b15de7b..019f4366479a3b5aa4bf69e57028e7dcefdca314 100644 (file)
@@ -129,7 +129,7 @@ hiketech_trkpt_pr(const waypoint* waypointp)
 {
   gbfprintf(ofd, " <pnt>\n");
   if (waypointp->creation_time) {
-    hiketech_print_utc(waypointp->creation_time, "  ", "utc");
+    hiketech_print_utc(waypointp->GetCreationTime(), "  ", "utc");
   }
   gbfprintf(ofd, "  <lat>%f</lat>\n", waypointp->latitude);
   gbfprintf(ofd, "  <long>%f</long>\n", waypointp->longitude);
@@ -259,7 +259,7 @@ void        ht_trk_utc(const char* args, const char** unused)
 
   utc = mkgmtime(&tm);
 
-  wpt_tmp->creation_time = utc;
+  wpt_tmp->SetCreationTime(utc);
 }
 
 static
index 3def99f587a2147f773a69df146df6ec126e1dbe..96fcf8af13a125ebafb566c1a3ccfb04a695bc0e 100644 (file)
@@ -120,7 +120,7 @@ static void data_read(void)
     wpt_tmp->shortname = xstrdup(name);
     wpt_tmp->description = xstrdup(desc);
 
-    wpt_tmp->creation_time = 0;
+    wpt_tmp->SetCreationTime(0);
     if (pWptHxTmp->date.year) {
 #if 0
       /* Unless there's some endian swapping that I don't see,
@@ -140,7 +140,7 @@ static void data_read(void)
       tm.tm_mday = pWptHxTmp->date.day;
       tm.tm_mon = pWptHxTmp->date.month - 1;
       tm.tm_year = pWptHxTmp->date.year - 1900;
-      wpt_tmp->creation_time = mktime(&tm);
+      wpt_tmp->SetCreationTime(mktime(&tm));
     }
 
     lon = le_read32(&pWptHxTmp->pt.iLongitude) / 36000.0;
@@ -227,8 +227,8 @@ static void holux_disp(const waypoint* wpt)
   /*set the time */
   if (wpt->creation_time) {
     /* tm = gmtime(&wpt->creation_time);*/  /* I get the wrong result with gmtime ???  */
-    QDate date(wpt->creation_time.date());
-    QTime time(wpt->creation_time.time());
+    QDate date(wpt->GetCreationTime().date());
+    QTime time(wpt->GetCreationTime().time());
     pWptHxTmp->time = (time.hour() * 3600) + (time.minute()* 60) + time.second();
     pWptHxTmp->date.day = date.day();
     pWptHxTmp->date.month = date.month();
index 11b7bd748900b3d1f221ba5793e9bc2f1ded38ea..7aef17962d3bdcd872af621b23d690340537ea46 100644 (file)
@@ -129,7 +129,7 @@ hsa_ndv_end(void* data, const XML_Char* xml_el)
       } else if (strcmp(el, "Longitude") == 0) {
         wpt_tmp->longitude = atof(cdatastr);
       } else if (strcmp(el, "Time") == 0) {
-        wpt_tmp->creation_time = atoi(cdatastr);
+        wpt_tmp->SetCreationTime(atoi(cdatastr));
       }
     }
   }
index c0764471d5d0fc6418482cce600778a4e4f45240..42c6f7c9dd9828aef0a62b64a0aec8996e778584 100644 (file)
@@ -81,7 +81,7 @@ html_disp(const waypoint* wpt)
 {
   char tbuf[1024];
   char* cout;
-  time_t tm = wpt->creation_time;
+  time_t tm = wpt->GetCreationTime();
   gbint32 utmz;
   double utme, utmn;
   char utmzc;
index 464b463066a0e62521129bb13123bba10897b1cd..88bc0ae34eb8157d77a25310b6b213bf48b393b1 100644 (file)
@@ -269,7 +269,7 @@ humminbird_read_wpt(gbfile* fin)
   wpt = waypt_new();
 
   wpt->shortname = xstrndup(w.name, sizeof(w.name));
-  wpt->creation_time = w.time;
+  wpt->SetCreationTime(w.time);
 
   guder = gudermannian_i1924(w.north);
   wpt->latitude = geocentric_to_geodetic_hwr(guder);
@@ -437,7 +437,7 @@ humminbird_read_track(gbfile* fin)
       /* Unless it's zero. Sometimes happens, possibly if
          the gps didn't have a lock when the track was
          saved. */
-      wpt->creation_time = th.time;
+      wpt->SetCreationTime(th.time);
     }
     track_add_wpt(trk, wpt);
   }
@@ -554,7 +554,7 @@ humminbird_read_track_old(gbfile* fin)
       /* Unless it's zero. Sometimes happens, possibly if
          the gps didn't have a lock when the track was
          saved. */
-      wpt->creation_time = th.time;
+      wpt->SetCreationTime(th.time);
     }
     track_add_wpt(trk, wpt);
   }
@@ -681,7 +681,7 @@ humminbird_write_waypoint(const waypoint* wpt)
   hum.depth = si_round(WAYPT_GET(wpt, depth, 0)*100.0);
   be_write16(&hum.depth, hum.depth);
 
-  be_write32(&hum.time, wpt->creation_time);
+  be_write32(&hum.time, wpt->GetCreationTime());
 
   east = wpt->longitude / 180.0 * EAST_SCALE;
   be_write32(&hum.east, si_round((east)));
@@ -782,7 +782,7 @@ humminbird_track_cb(const waypoint* wpt)
   north = si_round(inverse_gudermannian_i1924(lat));
 
   if (wpt->creation_time != 0) {
-    last_time = wpt->creation_time;
+    last_time = wpt->GetCreationTime();
   }
 
   if (i == 0) {
index 6357e22de8618d51e17c2faa8fe61ba5c7282d8e..52375aecff94c5d763d97f7f8b4979f19201300a 100644 (file)
@@ -206,7 +206,7 @@ static void igc_task_rec(const char* rec)
   wpt->longitude = ('E' == lon_hemi[0] ? 1 : -1) *
                    (lon_deg + (lon_min * 1000 + lon_frac) / 1000.0 / 60);
 
-  wpt->creation_time = creation;
+  wpt->SetCreationTime(creation);
   wpt->description = xstrdup(tmp_str);
 
   // Name the waypoint according to the order of the task record
@@ -364,7 +364,7 @@ static void data_read(void)
         date += 24 * 60 * 60;
       }
       prev_tod = tod;
-      pres_wpt->creation_time = date + tod;
+      pres_wpt->SetCreationTime(date + tod);
 
       // Add the waypoint to the pressure altitude track
       if (pres_alt) {
@@ -582,7 +582,7 @@ static void wr_header(void)
   }
   // Date in header record is that of the first fix record
   date = !track ? current_time() :
-         ((waypoint*) QUEUE_FIRST(&track->waypoint_list))->creation_time;
+         ((waypoint*) QUEUE_FIRST(&track->waypoint_list))->GetCreationTime();
 
   if (NULL == (tm = gmtime(&date))) {
     fatal(MYNAME ": Bad track timestamp\n");
@@ -648,7 +648,7 @@ static void wr_task_hdr(const route_head* rte)
     fatal(MYNAME ": Too much waypoints (more than 99) in task route.\n");
   }
   // Gather data to write to the task identification (first) record
-  rte_time = wpt->creation_time ? wpt->creation_time : current_time();
+  rte_time = wpt->GetCreationTime() ? wpt->GetCreationTime() : current_time();
   if (NULL == (tm = gmtime(&rte_time))) {
     fatal(MYNAME ": Bad task route timestamp\n");
   }
@@ -692,7 +692,7 @@ static void wr_fix_record(const waypoint* wpt, int pres_alt, int gnss_alt)
 {
   struct tm* tm;
 
-  const time_t tt = wpt->creation_time;
+  const time_t tt = wpt->GetCreationTime();
   tm = gmtime(&tt);
 
   if (NULL == tm) {
@@ -742,7 +742,7 @@ static int correlate_tracks(const route_head* pres_track, const route_head* gnss
       return 0;
     }
   } while (alt_diff > -10.0);
-  pres_time = ((waypoint*) elem->next)->creation_time;
+  pres_time = ((waypoint*) elem->next)->GetCreationTime();
   if (global_opts.debug_level >= 1) {
     printf(MYNAME ": pressure landing time %s", ctime(&pres_time));
   }
@@ -758,7 +758,7 @@ static int correlate_tracks(const route_head* pres_track, const route_head* gnss
       return 0;
     }
     // Get a crude indication of groundspeed from the change in lat/lon
-    time_diff = wpt->creation_time - ((waypoint*) elem)->creation_time;
+    time_diff = wpt->GetCreationTime() - ((waypoint*) elem)->GetCreationTime();
     speed = !time_diff ? 0 :
             (fabs(wpt->latitude - ((waypoint*) elem)->latitude) +
              fabs(wpt->longitude - ((waypoint*) elem)->longitude)) / time_diff;
@@ -766,7 +766,7 @@ static int correlate_tracks(const route_head* pres_track, const route_head* gnss
       printf(MYNAME ": speed=%f\n", speed);
     }
   } while (speed < 0.00003);
-  gnss_time = ((waypoint*) elem->next)->creation_time;
+  gnss_time = ((waypoint*) elem->next)->GetCreationTime();
   if (global_opts.debug_level >= 1) {
     printf(MYNAME ": gnss landing time %s", ctime(&gnss_time));
   }
@@ -797,7 +797,7 @@ static double interpolate_alt(const route_head* track, time_t time)
     curr_elem = prev_elem = QUEUE_FIRST(&track->waypoint_list);
   }
   // Find the track points either side of the requested time
-  while (((waypoint*) curr_elem)->creation_time < time) {
+  while (((waypoint*) curr_elem)->GetCreationTime() < time) {
     if (QUEUE_LAST(&track->waypoint_list) == curr_elem) {
       // Requested time later than all track points, we can't interpolate
       return unknown_alt;
@@ -810,7 +810,7 @@ static double interpolate_alt(const route_head* track, time_t time)
   curr_wpt = (waypoint*) curr_elem;
 
   if (QUEUE_FIRST(&track->waypoint_list) == curr_elem) {
-    if (curr_wpt->creation_time == time) {
+    if (curr_wpt->GetCreationTime() == time) {
       // First point's creation time is an exact match so use it's altitude
       return curr_wpt->altitude;
     } else {
@@ -819,12 +819,12 @@ static double interpolate_alt(const route_head* track, time_t time)
     }
   }
   // Interpolate
-  if (0 == (time_diff = curr_wpt->creation_time - prev_wpt->creation_time)) {
+  if (0 == (time_diff = curr_wpt->GetCreationTime() - prev_wpt->GetCreationTime())) {
     // Avoid divide by zero
     return curr_wpt->altitude;
   }
   alt_diff = curr_wpt->altitude - prev_wpt->altitude;
-  return prev_wpt->altitude + (alt_diff / time_diff) * (time - prev_wpt->creation_time);
+  return prev_wpt->altitude + (alt_diff / time_diff) * (time - prev_wpt->GetCreationTime());
 }
 
 /*
@@ -861,7 +861,7 @@ static void wr_track(void)
     // Iterate through waypoints in both tracks simultaneously
     QUEUE_FOR_EACH(&gnss_track->waypoint_list, elem, tmp) {
       wpt = (waypoint*) elem;
-      pres_alt = interpolate_alt(pres_track, wpt->creation_time + time_adj);
+      pres_alt = interpolate_alt(pres_track, wpt->GetCreationTime() + time_adj);
       wr_fix_record(wpt, (int) pres_alt, (int) wpt->altitude);
     }
   } else {
index 61c72bbdbd4d552a05136843127bb037790c938a..726830bdca1cea17a447e086edc00a8ddb4f5fa8 100644 (file)
@@ -219,7 +219,7 @@ static void write_igo8_track_point(const waypoint* wpt)
   if (wpt->creation_time == 0) {
     le_write32(&point.unix_time, invented_time++);
   } else {
-    le_write32(&point.unix_time, wpt->creation_time);
+    le_write32(&point.unix_time, wpt->GetCreationTime());
   }
 
   // Write the first part of the Information Block, the start time
index 76bd3be099b4c5e03a68fa3d847c574d1f59ac36..70f8483749367c20fe9fed4c1368d253d01fc435 100644 (file)
@@ -219,8 +219,7 @@ jtr_read(void)
 
     wpt->latitude = lat;
     wpt->longitude = lon;
-    wpt->creation_time = time;
-    wpt->microseconds = micros;
+    wpt->SetCreationTime(time, micros);
     if (speed >= 0) {
       WAYPT_SET(wpt, speed, speed);
     }
@@ -275,7 +274,7 @@ jtr_trkpt_disp_cb(const waypoint* wpt)
   struct tm tm;
 
   if (wpt->creation_time > 0) {
-    const time_t tt = wpt->creation_time;
+    const time_t tt = wpt->GetCreationTime();
     tm = *gmtime(&tt);
 
     tm.tm_year += 1900;
index f61aee3bd0b184b1e25ff9d50bd038901a479a1c..1bd895ec6ec2049f3d6b7c6f5064877e9853be95 100644 (file)
@@ -81,8 +81,8 @@ typedef enum  {
 
 static int realtime_positioning;
 static bounds kml_bounds;
-static time_t kml_time_min;
-static time_t kml_time_max;
+static gpsbabel::DateTime kml_time_min;
+static gpsbabel::DateTime kml_time_max;
 
 #define AUTOFORMATTING_OFF(AF) bool AF=writer->autoFormatting(); writer->setAutoFormatting(false);
 #define AUTOFORMATTING_RESTORE(AF) writer->setAutoFormatting(af);
@@ -605,16 +605,13 @@ static void kml_write_bitmap_style(kml_point_type pt_type, const char* bitmap,
 
 static void kml_output_timestamp(const waypoint* waypointp)
 {
-  if (waypointp->creation_time) {
-    char time_string[64];
-    xml_fill_in_time(time_string, waypointp->creation_time, waypointp->microseconds, XML_LONG_TIME);
-    if (time_string[0]) {
-      writer->writeStartElement("TimeStamp");
-      AUTOFORMATTING_OFF(af); // FIXME: we turn off autoformatting just to match old writer test references.
-      writer->writeTextElement("when", time_string);
-      writer->writeEndElement(); // Close TimeStamp tag
-      AUTOFORMATTING_RESTORE(af);
-    }
+  QString time_string = waypointp->CreationTimeXML();
+  if(!time_string.isEmpty()) {
+    writer->writeStartElement("TimeStamp");
+    AUTOFORMATTING_OFF(af); // FIXME: we turn off autoformatting just to match old writer test references.
+    writer->writeTextElement("when", time_string);
+    writer->writeEndElement(); // Close TimeStamp tag
+    AUTOFORMATTING_RESTORE(af);
   }
 }
 
@@ -717,9 +714,9 @@ void kml_output_trkdescription(const route_head* header, computed_trkdata* td)
   if (td->start && td->end) {
     char time_string[64];
 
-    xml_fill_in_time(time_string, td->start, 0, XML_LONG_TIME);
+    xml_fill_in_time(time_string, td->start, XML_LONG_TIME);
     kml_td(hwriter, "Start Time", QString(" %1 ").arg(time_string));
-    xml_fill_in_time(time_string, td->end, 0, XML_LONG_TIME);
+    xml_fill_in_time(time_string, td->end, XML_LONG_TIME);
     kml_td(hwriter, "End Time", QString(" %1 ").arg(time_string));
   }
 
@@ -735,9 +732,9 @@ void kml_output_trkdescription(const route_head* header, computed_trkdata* td)
   if (td->start && td->end) {
     char time_string[64];
     writer->writeStartElement("TimeSpan");
-    xml_fill_in_time(time_string, td->start, 0, XML_LONG_TIME);
+    xml_fill_in_time(time_string, td->start, XML_LONG_TIME);
     writer->writeTextElement("begin", time_string);
-    xml_fill_in_time(time_string, td->end, 0, XML_LONG_TIME);
+    xml_fill_in_time(time_string, td->end, XML_LONG_TIME);
     writer->writeTextElement("end", time_string);
     writer->writeEndElement(); // Close TimeSpan tag
   }
@@ -864,13 +861,10 @@ static void kml_output_description(const waypoint* pt)
   /* This really shouldn't be here, but as of this writing,
    * Earth can't edit/display the TimeStamp.
    */
-  if (pt->creation_time) {
-    char time_string[64];
-
-    xml_fill_in_time(time_string, pt->creation_time,
-                     pt->microseconds, XML_LONG_TIME);
-    if (time_string[0]) {
-      kml_td(hwriter, QString("Time: %1 ").arg(time_string));
+  if (pt->GetCreationTime()) {
+    QString time_string = pt->CreationTimeXML();
+    if(!time_string.isEmpty()) {
+      kml_td(hwriter, QString("Time: %1 ").arg(time_string));  
     }
   }
 
@@ -883,13 +877,13 @@ static void kml_output_description(const waypoint* pt)
 
 static void kml_recompute_time_bounds(const waypoint* waypointp)
 {
-  if (waypointp->creation_time && (waypointp->creation_time < kml_time_min)) {
-    kml_time_min = waypointp->creation_time;
+  if (waypointp->GetCreationTime() && (waypointp->GetCreationTime() < kml_time_min)) {
+    kml_time_min = waypointp->GetCreationTime();
   }
-  if (waypointp->creation_time > kml_time_max) {
-    kml_time_max = waypointp->creation_time;
+  if (waypointp->GetCreationTime() > kml_time_max) {
+    kml_time_max = waypointp->GetCreationTime();
     if (kml_time_min == 0) {
-      kml_time_min = waypointp->creation_time;
+      kml_time_min = waypointp->GetCreationTime();
     }
   }
 }
@@ -1459,7 +1453,7 @@ static void kml_geocache_pr(const waypoint* waypointp)
   kml_output_timestamp(waypointp);
   if (waypointp->creation_time) {
     strcpy(date_placed,
-           qPrintable(waypointp->creation_time.toString("dd-MMM-yyyy")));
+           qPrintable(waypointp->GetCreationTime().toString("dd-MMM-yyyy")));
   } else {
     date_placed[0] = '\0';
   }
@@ -1736,13 +1730,9 @@ static void kml_mt_hdr(const route_head* header)
   QUEUE_FOR_EACH(&header->waypoint_list, elem, tmp) {
     waypoint* tpt = (waypoint*)elem;
 
-    if (tpt->creation_time) {
-      char time_string[64];
-      xml_fill_in_time(time_string, tpt->creation_time, tpt->microseconds,
-                       XML_LONG_TIME);
-      if (time_string[0]) {
-        writer->writeTextElement("when", time_string);
-      }
+    if (tpt->GetCreationTime()) {
+      QString time_string = tpt->CreationTimeXML();
+      writer->writeOptionalTextElement("when", time_string);
     } else {
       writer->writeStartElement("when");
       writer->writeEndElement(); // Close when tag
@@ -1862,7 +1852,7 @@ void kml_write_AbstractView(void)
     writer->writeStartElement("gx:TimeSpan");
     if (kml_time_min) {
       char time_string[64];
-      xml_fill_in_time(time_string, kml_time_min, 0, XML_LONG_TIME);
+      xml_fill_in_time(time_string, kml_time_min, XML_LONG_TIME);
       if (time_string[0]) {
         writer->writeTextElement("begin", time_string);
       }
@@ -1878,7 +1868,7 @@ void kml_write_AbstractView(void)
       // ensure the right edge of that time slider includes us.
       //
       time_max = realtime_positioning ? kml_time_max + 600 : kml_time_max;
-      xml_fill_in_time(time_string, time_max, 0, XML_LONG_TIME);
+      xml_fill_in_time(time_string, time_max, XML_LONG_TIME);
       if (time_string[0]) {
         writer->writeTextElement("end", time_string);
       }
@@ -2104,7 +2094,7 @@ static route_head* posn_trk_head = NULL;
 static void
 kml_wr_position(waypoint* wpt)
 {
-  static time_t last_valid_fix;
+  static gpsbabel::DateTime last_valid_fix;
 
   kml_wr_init(posnfilenametmp);
 
@@ -2136,10 +2126,10 @@ kml_wr_position(waypoint* wpt)
   case fix_unknown:
     break;
   default:
-    last_valid_fix = wpt->creation_time;
+    last_valid_fix = wpt->GetCreationTime();
   }
 
-  wpt->icon_descr = kml_get_posn_icon(wpt->creation_time - last_valid_fix);
+  wpt->icon_descr = kml_get_posn_icon(wpt->GetCreationTime() - last_valid_fix);
 
 
   /* In order to avoid clutter while we're sitting still, don't add
index 7b56c3b5c51476d76268a4335037c7d3522ba8e3..984922bb9fd596876a107b4d974adf8d297314c5 100644 (file)
@@ -993,8 +993,7 @@ mag_trkparse(char* trkmsg)
   dmy = dmy / 100;
   tm.tm_mday = dmy % 100;
 
-  waypt->creation_time = mkgmtime(&tm);
-  waypt->microseconds = CENTI_TO_MICRO(fracsecs);
+  waypt->SetCreationTime(mkgmtime(&tm), CENTI_TO_MICRO(fracsecs));
 
   if (latdir == 'S') {
     latdeg = -latdeg;
@@ -1443,7 +1442,7 @@ void mag_track_disp(const waypoint* waypointp)
   ilon = waypointp->longitude;
   tm = NULL;
   if (waypointp->creation_time) {
-    const time_t ct = waypointp->creation_time;
+    const time_t ct = waypointp->GetCreationTime();
     tm = gmtime(&ct);
     if (tm) {
       hms = tm->tm_hour * 10000 + tm->tm_min  * 100 +
index 31d18d7d924401e34e7089fe5e59841d41431e7c..8ae4e2e033745b0def4ec00ae51a9fd69e0442f1 100644 (file)
@@ -233,7 +233,8 @@ static void
 mapsend_read(void)
 {
   mapsend_hdr hdr;
-  int type, len;
+  int type;
+  gbsize_t len;
   char buf[3];
 
   /*
@@ -471,7 +472,7 @@ void mapsend_track_hdr(const route_head* trk)
 void mapsend_track_disp(const waypoint* wpt)
 {
   unsigned char c;
-  int t;
+  gbint32 t;
   static int last_time;
 
   /*
@@ -484,7 +485,7 @@ void mapsend_track_disp(const waypoint* wpt)
    *
    * This is rumoured (but yet unconfirmed) to be fixed in f/w 5.12.
    */
-  t = wpt->creation_time;
+  t = wpt->GetCreationTime();
   if (t < last_time)  {
     t = last_time;
   }
index 690bf342d7d251975c55f8420d017adb59b788e7..3d10c591ae7e0bf13c50974f1e2abc322747647f 100644 (file)
@@ -1148,7 +1148,7 @@ mps_routehdr_w(gbfile* mps_file, int mps_ver, const route_head* rte)
     QUEUE_FOR_EACH(&rte->waypoint_list, elem, tmp) {
       testwpt = (waypoint*)elem;
       if (rte_datapoints == 0) {
-        uniqueValue = testwpt->creation_time;
+        uniqueValue = testwpt->GetCreationTime();
       }
       if (testwpt->latitude > maxlat) {
         maxlat = testwpt->latitude;
@@ -1544,8 +1544,7 @@ mps_track_r(gbfile* mps_file, int mps_ver, route_head** trk)
     thisWaypoint = waypt_new();
     thisWaypoint->latitude = GPS_Math_Semi_To_Deg(lat);
     thisWaypoint->longitude = GPS_Math_Semi_To_Deg(lon);
-    thisWaypoint->creation_time = dateTime;
-    thisWaypoint->microseconds = 0;
+    thisWaypoint->SetCreationTime(dateTime);
     thisWaypoint->altitude = mps_altitude;
     if (mps_depth != unknown_alt) {
       WAYPT_SET(thisWaypoint, depth, mps_depth);
@@ -1582,7 +1581,7 @@ mps_trackhdr_w(gbfile* mps_file, int mps_ver, const route_head* trk)
     QUEUE_FOR_EACH(&trk->waypoint_list, elem, tmp) {
       if (trk_datapoints == 0) {
         testwpt = (waypoint*)elem;
-        uniqueValue = testwpt->creation_time;
+        uniqueValue = testwpt->GetCreationTime();
       }
       trk_datapoints++;
     }
@@ -1637,7 +1636,7 @@ static void
 mps_trackdatapoint_w(gbfile* mps_file, int mps_ver, const waypoint* wpt)
 {
   int lat, lon;
-  time_t       t = wpt->creation_time;
+  time_t       t = wpt->GetCreationTime();
   char zbuf[10];
 
   double       mps_altitude = wpt->altitude;
index 761938f8e3bb4f8a6939d878fc7bc6bddd876f1e..cf91d906ed4dd63409190b44703aa5b1e55527bb 100644 (file)
@@ -491,7 +491,7 @@ mmo_read_CObjWaypoint(mmo_data_t* data)
     time = data->ctime;
   }
   if (time > 0) {
-    wpt->creation_time = time;
+    wpt->SetCreationTime(time);
   }
 
   if (mmo_version >= 0x18) {
@@ -726,7 +726,7 @@ mmo_read_CObjTrack(mmo_data_t* data)
     unk = gbfgetc(fin);
     DBG((sobj, "Unknown = 0x%02X (%d)\n", unk, unk));
 
-    wpt->creation_time = gbfgetint32(fin);
+    wpt->SetCreationTime(gbfgetint32(fin));
     wpt->altitude = gbfgetflt(fin);
 
     if (unk != 0) {
index 15efd00f1d6826565270d06a5053545102093ec5..e977538a2828a7be7f0e9faa4ecc7d6a2c0e1b89 100644 (file)
@@ -437,8 +437,7 @@ process_pmtklox()
 
     if (global_opts.masked_objective & TRKDATAMASK) {
       trkpt  = waypt_new();
-      trkpt->creation_time = timestamp;
-      trkpt->microseconds = 0;
+      trkpt->SetCreationTime(timestamp);
       trkpt->latitude = latitude;
       trkpt->longitude = longitude;
       trkpt->altitude = height;
@@ -450,8 +449,7 @@ process_pmtklox()
 
     if (global_opts.masked_objective & WPTDATAMASK) {
       waypt  = waypt_new();
-      waypt->creation_time = timestamp;
-      waypt->microseconds = 0;
+      waypt->SetCreationTime(timestamp);
       waypt->latitude = latitude;
       waypt->longitude = longitude;
       waypt->altitude = height;
index 848f999d7fc682ba0070ffbefb119cb9f5878b06..f530b56788f4519d8e1773469aae4b4c52895e3b 100644 (file)
@@ -177,7 +177,7 @@ nav_start(void* data, const XML_Char* xml_el, const XML_Char** xml_attr)
         tm.tm_hour = 0;
         tm.tm_min = 0;
         tm.tm_sec = 0;
-        wpt_tmp->creation_time = mktime(&tm);
+        wpt_tmp->SetCreationTime(mktime(&tm));
       } else if (0 == strcmp(ap[0], "retired")) {
         if (!strcmp(ap[1], "yes") && noretired) {
           xfree(wpt_tmp);
index a2d1bdc6f5d1ea1a45f9a271ec3b0f4cb2022d88..562cd18ede68877801fb2e863b1f6540e335ad32 100644 (file)
@@ -415,7 +415,7 @@ decode_waypoint(const unsigned char* buffer)
   decode_position(buffer + 12, waypt);
   waypt->shortname = xstrdup((char*)buffer + 4);
   waypt->icon_descr = icon_table[buffer[28]];
-  waypt->creation_time = decode_datetime(buffer + 22);
+  waypt->SetCreationTime(decode_datetime(buffer + 22));
 
   return waypt;
 }
@@ -430,7 +430,7 @@ encode_waypoint(const waypoint* waypt, unsigned char* buffer)
   buffer[10] = 0;
   buffer[11] = 0;
   encode_position(waypt, buffer + 12);
-  encode_datetime(waypt->creation_time, buffer + 22);
+  encode_datetime(waypt->GetCreationTime(), buffer + 22);
   buffer[28] = find_icon_from_descr(waypt->icon_descr);
   buffer[29] = 0;
   buffer[30] = 0x00;
@@ -443,7 +443,7 @@ decode_trackpoint(const unsigned char* buffer)
   waypoint* waypt = waypt_new();
 
   decode_position(buffer + 12, waypt);
-  waypt->creation_time = decode_datetime(buffer + 22);
+  waypt->SetCreationTime(decode_datetime(buffer + 22));
   WAYPT_SET(waypt, course, le_read16(buffer + 2));
   WAYPT_SET(waypt, speed, KPH_TO_MPS(buffer[29] * 2));
 
@@ -465,7 +465,7 @@ encode_trackpoint(const waypoint* waypt, unsigned serial, unsigned char* buffer)
   le_write32(buffer + 4, x);
   le_write32(buffer + 8, y);
   encode_position(waypt, buffer + 12);
-  encode_datetime(waypt->creation_time, buffer + 22);
+  encode_datetime(waypt->GetCreationTime(), buffer + 22);
   buffer[28] = z;
   buffer[29] = MPS_TO_KPH(WAYPT_GET(waypt, speed, 0) / 2);
   buffer[30] = 0x5a;
@@ -852,7 +852,7 @@ navilink_decode_logpoint(const unsigned char* buffer)
   waypt->hdop = ((unsigned char)buffer[0]) * 0.2f;
   waypt->sat = buffer[1];
   waypt->microseconds = decode_sbp_usec(buffer + 2);
-  waypt->creation_time = decode_sbp_datetime_packed(buffer + 4);
+  waypt->SetCreationTime(decode_sbp_datetime_packed(buffer + 4));
   decode_sbp_position(buffer + 12, waypt);
   WAYPT_SET(waypt, speed, le_read16(buffer + 24) * 0.01f);
   WAYPT_SET(waypt, course, le_read16(buffer + 26) * 0.01f);
index 1584f4bd782335cdb765d615854920168b244771..f939bbf42397aa452d120dabfb320574f34c4479 100644 (file)
@@ -899,7 +899,7 @@ nmea_fix_timestamps(route_head* track)
           wpt->creation_time+=SECONDS_PER_DAY;
         }
       }
-      prev = wpt->creation_time;
+      prev = wpt->GetCreationTime();
     }
   }
 }
@@ -1261,19 +1261,19 @@ nmea_trackpt_pr(const waypoint* wpt)
       if (sleepus >= 0) {
         gb_sleep(sleepus);
       } else {
-        long wait_time = wpt->creation_time - last_time;
+        long wait_time = wpt->GetCreationTime() - last_time;
         if (wait_time > 0) {
           gb_sleep(wait_time * 1000000);
         }
       }
     }
-    last_time = wpt->creation_time;
+    last_time = wpt->GetCreationTime();
   }
 
   lat = degrees2ddmm(wpt->latitude);
   lon = degrees2ddmm(wpt->longitude);
 
-  time_t ct = wpt->creation_time;
+  time_t ct = wpt->GetCreationTime();
   tm = gmtime(&ct);
   if (tm) {
     hms = tm->tm_hour * 10000 + tm->tm_min * 100 + tm->tm_sec;
index 345dd01d144eeca34dd9054a4f41fddb70517405..ea14f997797055b26ef7e5772bbb95cb01b8da13 100644 (file)
@@ -802,9 +802,8 @@ osm_waypt_disp(const waypoint* wpt)
 
     gbfprintf(fout, "  <node id='%d' visible='true' lat='%0.7f' lon='%0.7f'", *id, wpt->latitude, wpt->longitude);
     if (wpt->creation_time) {
-      char time_string[64];
-      xml_fill_in_time(time_string, wpt->creation_time, wpt->microseconds, XML_LONG_TIME);
-      gbfprintf(fout, " timestamp='%s'", time_string);
+      QString time_string = wpt->CreationTimeXML();
+      gbfprintf(fout, " timestamp='%s'", qPrintable(time_string));
     }
     gbfprintf(fout, ">\n");
 
index dd2304be6e0d7c2d357efa47feaf97ce837b0199..3c39c6b61e91a32e16c3e9b4e86ec62fd952db22 100644 (file)
@@ -166,7 +166,7 @@ ozi_set_time_str(const char *str, waypoint *waypointp)
   int len;
 
   ozi_time = atof(str);
-  waypointp->creation_time = (ozi_time - DAYS_SINCE_1990) * SECONDS_PER_DAY;
+  waypointp->SetCreationTime((ozi_time - DAYS_SINCE_1990) * SECONDS_PER_DAY);
 
   dot = strchr(str, '.');
   /* get number of characters after dot */
index 8e3d656cda24d5feba984b8dbb4b19ce06b24235..6cb77fb947927a16e08d5048521d71c23b820af0 100644 (file)
@@ -405,7 +405,7 @@ palmdoc_disp(const waypoint *wpt)
 {
   int latint, lonint;
   char tbuf[1024];
-  time_t tm = wpt->creation_time;
+  time_t tm = wpt->GetCreationTime();
   int32 utmz;
   double utme, utmn;
   char utmzc;
index 914b75d6ffd8ba04096cf5015a037cefbbe4d8c2..5428160710aa54753495589b7ba615ed67003bbe 100644 (file)
@@ -691,7 +691,7 @@ static void ppdb_write_wpt(const waypoint *wpt)
 
   if (wpt->creation_time != 0) {
     tmp = str_pool_get(20);
-    const time_t tt = wpt->creation_time;
+    const time_t tt = wpt->GetCreationTime();
     tm = *gmtime(&tt);
     strftime(tmp, 20, datefmt, &tm);
     buff = ppdb_strcat(buff, tmp, NULL, &len);
index 979f21d8cb98166ae3182d4a213c70423239ceda..b4a463d4bf1825bad5f2e1a3972ab6a468b57787 100644 (file)
@@ -254,7 +254,7 @@ data_read(void)
         tm.tm_year += 100;
       }
       wpt_tmp = waypt_new();
-      wpt_tmp->creation_time = mkgmtime(&tm);
+      wpt_tmp->SetCreationTime(mkgmtime(&tm));
       if (read_as_degrees) {
         wpt_tmp->longitude = lon;
         wpt_tmp->latitude = lat;
@@ -321,7 +321,7 @@ gpsutil_disp(const waypoint *wpt)
   double lon,lat;
   int icon_token = 0;
   char tbuf[1024];
-  time_t tm = wpt->creation_time;
+  time_t tm = wpt->GetCreationTime();
 
   lon = degrees2ddmm(wpt->longitude);
   lat = degrees2ddmm(wpt->latitude);
@@ -407,7 +407,7 @@ pcx_track_disp(const waypoint *wpt)
   lon = degrees2ddmm(wpt->longitude);
   lat = degrees2ddmm(wpt->latitude);
 
-  const time_t ct = wpt->creation_time;
+  const time_t ct = wpt->GetCreationTime();
   tm = gmtime(&ct);
 
   strftime(tbuf, sizeof(tbuf), "%d-%b-%y %H:%M:%S", tm);       /* currently ...%T does nothing under Windows */
index 76336ce789f679c5496936593b01481fbcecc460..652193b9cffeb58de119de682fd465ad1fc3dfe0 100644 (file)
@@ -108,7 +108,7 @@ read_tracks(void)
     wpt->latitude = le_read_float(&bc.latitude);
     wpt->longitude = le_read_float(&bc.longitude);
     wpt->altitude = FEET_TO_METERS(le_read_float(&bc.altitude));
-    wpt->creation_time = mkgmtime(&tm);
+    wpt->SetCreationTime(mkgmtime(&tm));
     wpt->hdop = le_read_float(&bc.ehpe);
     wpt->vdop = le_read_float(&bc.evpe);
     wpt->pdop = le_read_float(&bc.espe);
@@ -132,10 +132,10 @@ pocketfms_waypt_disp(const waypoint *wpt)
   struct tm *tm;
 
   memset(&bc, 0, sizeof(bc));
-  const time_t tt = wpt->creation_time;
+  const time_t tt = wpt->GetCreationTime();
   tm = localtime(&tt);
   if (wpt->creation_time) {
-    const time_t tt = wpt->creation_time;
+    const time_t tt = wpt->GetCreationTime();
     tm = gmtime(&tt);
   }
 
index ed119acb88ef52094e5e988312932a19a1b19a57..5fed711a3a471b405beaa803c0397303b1f89361 100644 (file)
@@ -488,7 +488,7 @@ psit_routehdr_w(gbfile *psit_file, const route_head *rte)
     QUEUE_FOR_EACH(&rte->waypoint_list, elem, tmp) {
       testwpt = (waypoint *)elem;
       if (rte_datapoints == 0) {
-        uniqueValue = testwpt->creation_time;
+        uniqueValue = testwpt->GetCreationTime();
       }
       rte_datapoints++;
     }
@@ -597,8 +597,9 @@ psit_track_r(gbfile *psit_file, route_head **trk)
 
       if ((strcmp(psit_current_token, "1") == 0) || (track_head == NULL)) {
         track_head = route_head_alloc();
-        /* Add a number to the track name.  With Garmins, the "first" tracklog is usually ACTIVE LOG
-           the second is ACTIVE LOG001 and so on */
+        /* Add a number to the track name.  With Garmins, the "first"
+         tracklog is usually ACTIVE LOG
+         the second is ACTIVE LOG001 and so on */
         if (trk_num > 0) {
           sprintf(tbuf, "%s%03d", trkname, trk_num);
           track_head->rte_name = xstrdup(tbuf);
@@ -608,14 +609,14 @@ psit_track_r(gbfile *psit_file, route_head **trk)
         trk_num++;
         track_add_head(track_head);
       }
-
-      thisWaypoint->creation_time = dateTime;
+      
+      thisWaypoint->SetCreationTime(dateTime);
       track_add_wpt(track_head, thisWaypoint);
-
+      
       if (gbfeof(psit_file)) {
         break;
       }
-
+      
       psit_getToken(psit_file,psit_current_token,sizeof(psit_current_token), wscomma);
     } else {
       break;
@@ -647,7 +648,7 @@ psit_trackhdr_w(gbfile *psit_file, const route_head *trk)
       QUEUE_FOR_EACH(&trk->waypoint_list, elem, tmp) {
         if (trk_datapoints == 0) {
           testwpt = (waypoint *)elem;
-          uniqueValue = testwpt->creation_time;
+          uniqueValue = testwpt->GetCreationTime();
         }
         trk_datapoints++;
       }
@@ -691,7 +692,7 @@ psit_trackhdr_w_wrapper(const route_head *trk)
 static void
 psit_trackdatapoint_w(gbfile *psit_file, const waypoint *wpt)
 {
-  time_t       t = wpt->creation_time;
+  time_t       t = wpt->GetCreationTime();
   struct tm *tmTime = gmtime(&t);
 
   gbfprintf(psit_file, "%11.6f,%11.6f,",
@@ -808,7 +809,8 @@ psit_write(void)
     route_disp_all(psit_routehdr_w_wrapper, psit_noop, psit_waypoint_w_wrapper);
   }
   if (global_opts.objective == trkdata) {
-    track_disp_all(psit_trackhdr_w_wrapper, psit_noop, psit_trackdatapoint_w_wrapper);
+    track_disp_all(psit_trackhdr_w_wrapper,
+                   psit_noop, psit_trackdatapoint_w_wrapper);
   }
 
   mkshort_del_handle(&mkshort_handle);
index 8d08f53397a42c8a5a30b3de27190305cdedaa9b..8303976794bcac43d7cc8d889b3a60a4196b3629 100644 (file)
@@ -218,7 +218,7 @@ raymarine_read(void)
       wpt->notes = xstrdup(str);
     }
     if (((str = inifile_readstr(fin, sect, "Time"))) && *str) {
-      wpt->creation_time = EXCEL_TO_TIMET(atof(str));
+      wpt->SetCreationTime(EXCEL_TO_TIMET(atof(str)));
     }
     if (((str = inifile_readstr(fin, sect, "Bmp"))) && *str) {
       unsigned int symbol = atoi(str);
@@ -349,7 +349,7 @@ write_waypoint(gbfile *fout, const waypoint *wpt, const int waypt_no, const char
     }
   }
   notes = csv_stringclean(notes, LINE_FEED);
-  time = (wpt->creation_time > 0) ? TIMET_TO_EXCEL(wpt->creation_time) : TIMET_TO_EXCEL(gpsbabel_time);
+  time = (wpt->creation_time > 0) ? TIMET_TO_EXCEL(wpt->GetCreationTime()) : TIMET_TO_EXCEL(gpsbabel_time);
   name = (char *)wpt->extra_data;
 
   gbfprintf(fout, "[Wp%d]" LINE_FEED
index 8761413a5133135b7e17065bc45f7fc1a44228cf..607f74c3cc4257f35d5459d6d29ee71ab309cbe5 100644 (file)
@@ -582,7 +582,7 @@ void track_recompute(const route_head *trk, computed_trkdata **trkdatap)
     double tlat, tlon, plat, plon, dist;
 
     thisw = (waypoint *)elem;
-    timed = thisw->creation_time - prev->creation_time;
+    timed = thisw->GetCreationTime() - prev->GetCreationTime();
 
     /*
      * gcdist and heading want radians, not degrees.
@@ -651,12 +651,12 @@ void track_recompute(const route_head *trk, computed_trkdata **trkdatap)
       tdata->max_cad = (int) thisw->cadence;
     }
 
-    if (thisw->creation_time && (thisw->creation_time < tdata->start)) {
-      tdata->start = thisw->creation_time;
+    if (thisw->GetCreationTime() && (thisw->GetCreationTime() < tdata->start)) {
+      tdata->start = thisw->GetCreationTime();
     }
 
     if (thisw->creation_time > tdata->end) {
-      tdata->end = thisw->creation_time;
+      tdata->end = thisw->GetCreationTime();
       if (tdata->start == 0) {
         tdata->start = tdata->end;
       }
index f8e6205e80c63bb600c3c97500442ca1f5fa5c45..3b01f4571a324ebbdb5da66af8844d9cec8825b2 100644 (file)
@@ -381,12 +381,11 @@ my_read(void)
             if (totaldist > seglen) {
               totaldist = seglen;
             }
-            wpt_tmp->creation_time =
+            wpt_tmp->SetCreationTime(
               gpsbabel_time+starttime+
-              transittime * totaldist/seglen;
+              transittime * totaldist/seglen);
           } else {
-            wpt_tmp->creation_time =
-              gpsbabel_time+starttime;
+            wpt_tmp->SetCreationTime(gpsbabel_time+starttime);
             totaldist = 0;
           }
           oldlat = lat;
index ffd5c03194859df20204100001b7c88d53114d15..7d57a21c2f51729b81c8b23e667a96faad70e73f 100644 (file)
@@ -225,7 +225,7 @@ decode_sbn_datetime(const unsigned char *buffer, waypoint *waypt)
   tm.tm_mon = buffer[2] - 1;
   tm.tm_year = be_readu16(buffer) - 1900;
 
-  waypt->creation_time = mkgmtime(&tm);
+  waypt->SetCreationTime(mkgmtime(&tm));
   waypt->microseconds = (ms % 1000) * 1000;
 }
 
index 10588614894f9ec935fe7c2f74e1f2ce7c41ce00..a78332233e44754d7acceb07b14ace09fde166d5 100644 (file)
@@ -113,7 +113,7 @@ skyforce_parse_trk(const char *str)
     fatal(MYNAME ": Could not parse date string (%s - %s).\n", buf, cx);
   }
 
-  wpt->creation_time = mkgmtime(&tm);
+  wpt->SetCreationTime(mkgmtime(&tm));
 
   len = strlen(str);
 
@@ -177,7 +177,7 @@ skyforce_waypt_disp_cb(const waypoint *wpt)
   if (global_opts.objective == trkdata) {
     struct tm tm;
 
-    const time_t tt = wpt->creation_time;
+    const time_t tt = wpt->GetCreationTime();
     tm = *gmtime(&tt);
     strftime(buf + 2, sizeof(buf) - 2, "%d%m%y  %H%M%S    ", &tm);
   } else {
index 9b6a71579163eb5a2a824519ffd9280d6a9769fc..f9ed3e480eea601b5b582ad635e8eabc7eeaa2ff 100644 (file)
@@ -663,7 +663,7 @@ make_trackpoint(struct read_state *st, double lat, double lon, double alt)
   wpt->latitude       = lat;
   wpt->longitude      = lon;
   wpt->altitude       = alt;
-  wpt->creation_time  = gpstime_to_timet(st->gps_week, st->gps_sec);
+  wpt->SetCreationTime(gpstime_to_timet(st->gps_week, st->gps_sec));
 
   return wpt;
 }
index 137e5e76a01198879185f752deeb7356363dc7ce..e0d49cd6f220d066cae0ebc584bc92514494a9d6 100644 (file)
@@ -186,9 +186,9 @@ compute_xte(struct xte *xte_rec)
       fatal(MYNAME ": relative needs hdop information.\n");
     }
     // if timestamps exist, distance to interpolated point
-    if (wpt1->creation_time != wpt2->creation_time) {
+    if (wpt1->GetCreationTime() != wpt2->GetCreationTime()) {
       frac = (double)(wpt3->creation_time - wpt1->creation_time) /
-             (wpt2->creation_time - wpt1->creation_time);
+             (wpt2->GetCreationTime() - wpt1->GetCreationTime());
       linepart(wpt1->latitude, wpt1->longitude,
                wpt2->latitude, wpt2->longitude,
                frac, &reslat, &reslon);
index b3c52634035883f5438efa4ef6027a57b14127cc..d13c67da7fcf3a8239032d7ce15d9d25ec291cce 100644 (file)
@@ -70,7 +70,7 @@ sort_comp(const queue * a, const queue * b)
   case sm_description:
     return strcmp(x1->description, x2->description);
   case sm_time:
-    return x1->creation_time - x2->creation_time;
+    return x1->GetCreationTime() - x2->GetCreationTime();
   default:
     abort();
     return 0; /* Internal caller error. */
index 0270ba81909b0272a0fb7083c1a6a3222a9c91de..4456d18d44deeffcfd7a94eb95d8387541e67403 100644 (file)
@@ -85,6 +85,9 @@ public:
   void addUSecs(qint64 usecs) const {
     this->addMSecs(usecs / 1000);
   }
+  int usec() const {
+    return this->time().msec() * 1000;
+  }
 
   // Integer form: YYMMDD
   int ymd() const {
index b2e548d5eaec1640046990eb816c60c5f01e5532..6534565bbfa821be554605e54b778f77c6b3d26e 100644 (file)
@@ -169,7 +169,7 @@ track_qsort_cb(const void *a, const void *b)
   const waypoint *wa = *(waypoint **)a;
   const waypoint *wb = *(waypoint **)b;
 
-  return wa->creation_time - wb->creation_time;
+  return wa->GetCreationTime() - wb->GetCreationTime();
 }
 
 static void
@@ -330,7 +330,7 @@ parse_point(char *line)
     tm.tm_min = min;
     tm.tm_sec = sec;
 
-    wpt->creation_time = mklocaltime(&tm);
+    wpt->SetCreationTime(mklocaltime(&tm));
   }
 
   if (datum != DATUM_WGS84) {
@@ -455,7 +455,7 @@ calculate(const waypoint *wpt, double *dist, double *speed, double *course,
       *dist = 0;  /* calc. diffs on 32- and 64-bit hosts */
     }
 
-    time = wpt->creation_time - trkpt_out->creation_time;
+    time = wpt->creation_time - trkpt_out->GetCreationTime();
     if (time == 0) {
       *speed = 0;
     } else {
@@ -526,7 +526,7 @@ any_waypt_calc_cb(const waypoint *wpt)
   }
 
   if ((all_points == 0) && (this_points == 0)) {
-    start_time = wpt->creation_time;
+    start_time = wpt->GetCreationTime();
   }
 
   this_points++;
@@ -544,7 +544,7 @@ any_waypt_calc_cb(const waypoint *wpt)
 
   this_distance = this_distance + dist;
   if (trkpt_out != NULL) {
-    this_time += (wpt->creation_time - trkpt_out->creation_time);
+    this_time += (wpt->GetCreationTime() - trkpt_out->GetCreationTime());
   }
 
   trkpt_out = (waypoint *)wpt;
@@ -585,7 +585,7 @@ track_disp_wpt_cb(const waypoint *wpt)
   track_points++;
   all_track_points++;
 
-  time_t ct = wpt->creation_time;
+  time_t ct = wpt->GetCreationTime();
   tm = *localtime(&ct);
   strftime(tbuf, sizeof(tbuf), "%d.%m.%Y,%H:%M.%S", &tm);
 
@@ -669,8 +669,8 @@ route_disp_wpt_cb(const waypoint *wpt)
 static void
 track_disp_custom_cb(const waypoint *wpt)
 {
-  if (wpt->creation_time && (wpt->altitude != unknown_alt)) {
-    gbfprintf(fout, "%d,%.f\n", (int)(wpt->creation_time - start_time), wpt->altitude);
+  if (wpt->GetCreationTime() && (wpt->altitude != unknown_alt)) {
+    gbfprintf(fout, "%d,%.f\n", (int)(wpt->GetCreationTime() - start_time), wpt->altitude);
   }
 }
 
index d50b9a6cf9433e158b85f0b6da6b8d6dacb471ec..8d627352d19f80e7da54f63dd0f0bdc06924a2fc 100644 (file)
@@ -166,7 +166,7 @@ stmwpp_data_read(void)
     if (wpt != NULL) {
       time.tm_year -= 1900;
       time.tm_mon--;
-      wpt->creation_time = mkgmtime(&time);
+      wpt->SetCreationTime(mkgmtime(&time));
 
       switch (what) {
       case STM_WAYPT:
@@ -239,7 +239,7 @@ stmwpp_waypt_cb(const waypoint *wpt)
     return;
   }
 
-  const time_t tt = wpt->creation_time;
+  const time_t tt = wpt->GetCreationTime();
   tm = *gmtime(&tt);
   tm.tm_year += 1900;
   tm.tm_mon++;
index 40f2c83ff1768c539233b36ca4c04f5fe4902524..dd48e2caf7d49cf81cbf040d253c3be3bef3b9f3 100644 (file)
@@ -92,17 +92,17 @@ subrip_prevwp_pr(const waypoint *waypointp)
   time_t starttime;
   time_t endtime;
 
-  if (prevwpp->creation_time >= time_offset)
+  if (prevwpp->GetCreationTime() >= time_offset)
     /* if this condition is not true, the waypoint is before the beginning of
      * the video and will be ignored
      */
   {
 
-    starttime = gps_to_video_time(prevwpp->creation_time);
+    starttime = gps_to_video_time(prevwpp->GetCreationTime());
     if (!waypointp) {
       endtime = starttime + 1;
     } else {
-      endtime = gps_to_video_time(waypointp->creation_time);
+      endtime = gps_to_video_time(waypointp->GetCreationTime());
     }
     gbfprintf(fout, "%d\n", stnum);
     stnum++;
@@ -120,7 +120,7 @@ subrip_prevwp_pr(const waypoint *waypointp)
     } else if WAYPT_HAS(prevwpp, speed) {
       gbfprintf(fout, "\n");
     }
-    subrip_write_time(prevwpp->creation_time);
+    subrip_write_time(prevwpp->GetCreationTime());
     gbfprintf(fout, " Lat=%0.5lf Lon=%0.5lf\n",
               prevwpp->latitude + .000005,
               prevwpp->longitude + .000005);
@@ -148,7 +148,7 @@ subrip_trkpt_pr(const waypoint *waypointp)
      * way of solving this should be trivial to you :-)
      */
   {
-    time_offset = sync_time(waypointp->creation_time, opt_videotime);
+    time_offset = sync_time(waypointp->GetCreationTime(), opt_videotime);
   }
 
   if (prevwpp) {
index ef2cd59c192dbb48129455d2d00d51965a618a1c..5eb127a9a1c07520ea42b2f2fdd4ff14737ef6d4 100644 (file)
@@ -97,7 +97,7 @@ text_disp(const waypoint *wpt)
 {
   int latint, lonint;
   char tbuf[1024];
-  time_t tm = wpt->creation_time;
+  time_t tm = wpt->GetCreationTime();
   gbint32 utmz;
   double utme, utmn;
   char utmzc;
index 8749c1ffed4e7a1044ab4de7e121457e2f7687f2..b39c836cd7803041b6d49b9956dee334c4d97711 100644 (file)
@@ -189,7 +189,7 @@ tiger_disp(const waypoint *wpt)
     pin = wpt->icon_descr;
   } else if (wpt->icon_descr.contains("-unfound")) {
     pin = unfoundmarker;
-  } else if (wpt->creation_time > current_time() - 3600 * 24 * thresh_days) {
+  } else if (wpt->GetCreationTime() > current_time() - 3600 * 24 * thresh_days) {
     pin = newmarker;
   } else {
     pin = oldmarker;
index 5bcdfcc01b0c5254d0bd10671fd49454bc38b17f..f8c0a01c647a5907e95304928b290be6f0508d0c 100644 (file)
@@ -269,7 +269,7 @@ trackfilter_merge_qsort_cb(const void *a, const void *b)
   const waypoint *wa = *(waypoint **)a;
   const waypoint *wb = *(waypoint **)b;
 
-  return wa->creation_time - wb->creation_time;
+  return wa->GetCreationTime() - wb->GetCreationTime();
 }
 
 static fix_type
@@ -344,17 +344,16 @@ trackfilter_fill_track_list_cb(const route_head *track)   /* callback for track_d
 
     i++;
     if (i == 1) {
-      track_list[track_ct].first_time = wpt->creation_time;
+      track_list[track_ct].first_time = wpt->GetCreationTime();
     } else if (i == track->rte_waypt_ct) {
-      track_list[track_ct].last_time = wpt->creation_time;
+      track_list[track_ct].last_time = wpt->GetCreationTime();
     }
 
-    if ((need_time != 0) && (prev != NULL) && (prev->creation_time > wpt->creation_time)) {
+    if ((need_time != 0) && (prev != NULL) && (prev->GetCreationTime() > wpt->GetCreationTime())) {
       if (opt_merge == NULL) {
-        char t1[64], t2[64];
-        xml_fill_in_time(t1, prev->creation_time, 0, XML_LONG_TIME);
-        xml_fill_in_time(t2, wpt->creation_time, 0, XML_LONG_TIME);
-        fatal(MYNAME "-init: Track points badly ordered (timestamp %s > %s)!\n", t1, t2);
+        QString t1 = prev->CreationTimeXML();
+        QString t2 = wpt->CreationTimeXML();
+        fatal(MYNAME "-init: Track points badly ordered (timestamp %s > %s)!\n", qPrintable(t1), qPrintable(t2));
       }
     }
     prev = wpt;
@@ -525,7 +524,7 @@ trackfilter_merge(void)
 
   for (i = 0; i < track_pts-timeless_pts; i++) {
     wpt = buff[i];
-    if ((prev == NULL) || (prev->creation_time != wpt->creation_time)) {
+    if ((prev == NULL) || (prev->GetCreationTime() != wpt->GetCreationTime())) {
       route_add_wpt(master, wpt);
       prev = wpt;
     } else {
@@ -708,7 +707,7 @@ trackfilter_split(void)
       }
 
       if (interval > 0) {
-        double tr_interval = difftime(buff[j]->creation_time,buff[i]->creation_time);
+        double tr_interval = difftime(buff[j]->GetCreationTime(),buff[i]->GetCreationTime());
         if (tr_interval <= interval) {
           new_track_flag = 0;
         }
@@ -725,7 +724,7 @@ trackfilter_split(void)
       printf(MYNAME ": splitting new track\n");
 #endif
       curr = (route_head *) route_head_alloc();
-      trackfilter_split_init_rte_name(curr, buff[j]->creation_time);
+      trackfilter_split_init_rte_name(curr, buff[j]->GetCreationTime());
       track_add_head(curr);
     }
     if (curr != NULL) {
@@ -812,12 +811,12 @@ trackfilter_synth(void)
                     RAD(wpt->longitude)));
         }
         if (opt_speed) {
-          if (oldtime != wpt->creation_time) {
+          if (oldtime != wpt->GetCreationTime()) {
             WAYPT_SET(wpt, speed, radtometers(gcdist(
                                                 RAD(oldlat), RAD(oldlon),
                                                 RAD(wpt->latitude),
                                                 RAD(wpt->longitude))) /
-                      labs(wpt->creation_time-oldtime));
+                      labs(wpt->GetCreationTime()-oldtime));
           } else {
             WAYPT_UNSET(wpt, speed);
           }
@@ -825,7 +824,7 @@ trackfilter_synth(void)
       }
       oldlat = wpt->latitude;
       oldlon = wpt->longitude;
-      oldtime = wpt->creation_time;
+      oldtime = wpt->GetCreationTime();
     }
   }
 }
@@ -893,7 +892,7 @@ trackfilter_range(void)             /* returns number of track points left after filtering
     QUEUE_FOR_EACH((queue *)&track->waypoint_list, elem, tmp) {
       waypoint *wpt = (waypoint *)elem;
       if (wpt->creation_time > 0) {
-        inside = ((wpt->creation_time >= start) && (wpt->creation_time <= stop));
+        inside = ((wpt->GetCreationTime() >= start) && (wpt->GetCreationTime() <= stop));
       }
       // If the time is mangled so horribly that it's
       // negative, toss it.
index f9da2f0feade398f5bb335d749c8c8d28854bd73..a55d8254d180388ea75e032edd0335e0a44dd0af 100644 (file)
@@ -1179,15 +1179,15 @@ unicsv_parse_one_line(char *ibuf)
 
       ymd.tm_mon--;
       if (opt_utc) {
-        wpt->creation_time = mkgmtime(&ymd);
+        wpt->SetCreationTime(mkgmtime(&ymd));
       } else {
-        wpt->creation_time = mklocaltime(&ymd);
+        wpt->SetCreationTime(mklocaltime(&ymd));
       }
     } else if (ymd.tm_hour || ymd.tm_min || ymd.tm_sec) {
       if (opt_utc) {
-        wpt->creation_time = mkgmtime(&ymd);
+        wpt->SetCreationTime(mkgmtime(&ymd));
       } else {
-        wpt->creation_time = mklocaltime(&ymd);
+        wpt->SetCreationTime(mklocaltime(&ymd));
       }
     }
 
@@ -1729,13 +1729,13 @@ unicsv_waypt_disp_cb(const waypoint *wpt)
     if (wpt->creation_time >= SECONDS_PER_DAY) {
       struct tm tm;
       char buf[32];
-      time_t time = wpt->creation_time;
+      time_t time = wpt->GetCreationTime();
 
       if (opt_utc) {
         time += atoi(opt_utc) * SECONDS_PER_HOUR;
         tm = *gmtime(&time);
       } else {
-        const time_t tt = wpt->creation_time;
+        const time_t tt = wpt->GetCreationTime();
         tm = *localtime(&tt);
       }
       tm.tm_year += 1900;
@@ -1750,13 +1750,13 @@ unicsv_waypt_disp_cb(const waypoint *wpt)
     if (wpt->creation_time != 0) {
       struct tm tm;
       char buf[32], msec[12];
-      time_t time = wpt->creation_time;
+      time_t time = wpt->GetCreationTime();
 
       if (opt_utc) {
         time += atoi(opt_utc) * SECONDS_PER_HOUR;
         tm = *gmtime(&time);
       } else {
-        const time_t tt = wpt->creation_time;
+        const time_t tt = wpt->GetCreationTime();
         tm = *localtime(&tt);
       }
       snprintf(buf, sizeof(buf), "%02d:%02d:%02d", tm.tm_hour, tm.tm_min, tm.tm_sec);
index 405f084edf4eafa091ef2c74a57b3a53ba5102a7..24d8533cfcf695b156ec405da46bb75b21d3fb03 100644 (file)
@@ -326,7 +326,7 @@ v900_read(void)
       int date, time;
       date = atoi(line.bas.common.date);
       time = atoi(line.bas.common.time);
-      wpt->creation_time = bintime2utc(date, time);
+      wpt->SetCreationTime(bintime2utc(date, time));
     }
 
     wpt->speed = KPH_TO_MPS(atoi(line.bas.common.speed));
index 5ee3856cab95f9f984a914cf7f684ae2a76ef2c4..bee5e1f390536f2c4f94723b1fcdbdc7baab37c0 100644 (file)
@@ -168,8 +168,8 @@ vitosmt_read(void)
     tmStruct.tm_sec    =(int)floor(seconds);
     tmStruct.tm_isdst  =-1;
 
-    wpt_tmp->creation_time = mkgmtime(&tmStruct);
-    wpt_tmp->microseconds = fmod(1000000*seconds+0.5,1000000);
+    wpt_tmp->SetCreationTime(mkgmtime(&tmStruct),
+                             fmod(1000000*seconds+0.5,1000000));
     wpt_tmp->shortname = (char*) xcalloc(16,1);
     snprintf(wpt_tmp->shortname, 15 , "WP%04d", ++serial);
 
@@ -254,8 +254,8 @@ vitosmt_waypt_pr(const waypoint *waypointp)
     WriteDouble(&workbuffer[position], waypointp->altitude);
   }
   position += sizeof(double);
-  QDate date(waypointp->creation_time.date());
-  QTime time(waypointp->creation_time.time());
+  QDate date(waypointp->GetCreationTime().date());
+  QTime time(waypointp->GetCreationTime().time());
   workbuffer[position++]       = date.year()-100;
   workbuffer[position++]       = date.month();
   workbuffer[position++]       = date.day();
index c4cc2f606bb9f4824c214c51a2d75a835ae46260..f486a6488df1e3d387e6c801a264efee073c83dc 100644 (file)
@@ -111,8 +111,7 @@ vitovtt_read(void)
 
     tmStruct.tm_sec = scaled_sec / vitovtt_secondscale;
     microseconds = (scaled_sec % vitovtt_secondscale) / vitovtt_microsecondscale;
-    wpt_tmp->creation_time     = mkgmtime(&tmStruct);
-    wpt_tmp->microseconds      = microseconds;
+    wpt_tmp->SetCreationTime(mkgmtime(&tmStruct), microseconds);
 
     /*
      * TODO: interpret speed, course, status
index 6eb21c77fccba9b768c9a69ac862c80c7e0edf4b..c1be36f804484c3df49670b8a60603b85a7796ca 100644 (file)
@@ -209,7 +209,7 @@ vpl_parse_75_sentence(const char *ibuf)
   waypt->hdop      = hdop_raw / (double) 8;
   waypt->vdop      = vdop_raw / (double) 8;
 
-  waypt->creation_time = mkgmtime(&tm);
+  waypt->SetCreationTime(mkgmtime(&tm));
 
   track_add_wpt(track_head, waypt);
 }
index 4df831532c44e537d51a9d02119db13db297ecf0..537a7fbb79f46f68696a5920a3f1f6c278b8f690 100644 (file)
@@ -659,3 +659,22 @@ waypt_empty_gc_data(const waypoint *wpt)
 {
   return (wpt->gc_data == &empty_gc_data);
 }
+
+QString
+waypoint::CreationTimeXML() const
+{
+  if (creation_time == 0) {
+    return NULL;
+  }
+
+  QDateTime dt = QDateTime::fromTime_t(creation_time);
+  dt = dt.addMSecs(MICRO_TO_MILLI(microseconds));
+  dt = dt.toUTC();
+
+  const char* format = "yyyy-MM-ddTHH:mm:ssZ";
+  if (dt.time().msec()) {
+    format = "yyyy-MM-ddTHH:mm:ss.zzzZ";
+  }
+
+  return dt.toString(format);
+}
index 1f70d51e1301cfb70c08fc0aee0a9b4e57f5327d..cd393da19b715c162f5c5cdd2a08f52e57a97f1d 100644 (file)
@@ -550,7 +550,7 @@ static waypoint *make_point(double lat, double lon, double alt, time_t tim, cons
   wpt->latitude       = lat;;
   wpt->longitude      = lon;
   wpt->altitude       = alt;
-  wpt->creation_time  = tim;
+  wpt->SetCreationTime(tim);
   wpt->shortname      = xstrdup(wp_name);
 
   return wpt;
index dca8454b12bc35ba3d940dda2dfc7b556ebc6332..5336c72fd9b227177d2df6286c4ddc1729f55a74 100644 (file)
@@ -255,7 +255,7 @@ void wfff_e(const char *args, const char **unused)
       }
     }
 
-    wpt_tmp->creation_time = ap_first;
+    wpt_tmp->SetCreationTime(ap_first);
 
     waypt_add(wpt_tmp);
 
index 5c1561dcde037438f88e77fa81e4493e8ea77a3e..1f1870b27f7758a494b9ae0894c20f7814db914a 100644 (file)
@@ -71,7 +71,7 @@ wintec_tes_read(void)
     wpt = waypt_new();
     wpt->latitude = latitude / 1.0e7;
     wpt->longitude = longitude / 1.0e7;
-    wpt->creation_time = wintec_date_to_time(date);
+    wpt->SetCreationTime(wintec_date_to_time(date));
     // The unit of altitude isn't clear and we have a lot of
     // samples with wildly negative values, so ignore those for now.
     wpt->altitude = alt;
index a14d529887bd1ea62c43cd83d3cc16ddda722d07..80a863de1a28711408aa1c3124c2f0f4ccb41843 100644 (file)
@@ -22,6 +22,7 @@
 #include "defs.h"
 #include "xmlgeneric.h"
 #include "cet_util.h"
+#include <QtCore/QDebug>
 
 #define DEBUG_TAG 0
 #if DEBUG_TAG
@@ -107,42 +108,30 @@ write_xml_entity_end(gbfile *ofd, const QString& indent,
 }
 
 void
-xml_fill_in_time(char *time_string, const time_t timep, int microseconds, int long_or_short)
+xml_fill_in_time(char *time_string, const time_t timep, int long_or_short)
 {
-  struct tm *tm = gmtime(&timep);
-  const char *format;
-  int n;
-
-  if (!tm) {
-    *time_string = 0;
-    return;
-  }
+  QDateTime dt = QDateTime::fromTime_t(timep);
+  dt = dt.toUTC();
 
+  const char* format;
   if (long_or_short == XML_LONG_TIME) {
-    format = "%02d-%02d-%02dT%02d:%02d:%02d";
+    format = "yyyy-MM-ddTHH:mm:ssZ";
+    if (dt.time().msec()) {
+fprintf(stderr, "this should not be possible");
+abort();
+      format = "yyyy-MM-ddTHH:mm:ss.zzzZ";
+    }
   } else {
-    format = "%02d%02d%02dT%02d%02d%02d";
-  }
-  n = sprintf(time_string, format,
-              tm->tm_year+1900,
-              tm->tm_mon+1,
-              tm->tm_mday,
-              tm->tm_hour,
-              tm->tm_min,
-              tm->tm_sec);
-  if (microseconds) {
-    n += sprintf(time_string + n, ".%03d", microseconds / 1000);
+    format = "yyyyMMddTHHmmssZ";
   }
-  time_string[n++] = 'Z';
-  time_string[n++] = '\0';
-
+  strcpy(time_string, qPrintable(dt.toString(format)));
 }
 
 void
 xml_write_time(gbfile *ofd, const time_t timep, int microseconds, const char *elname)
 {
   char time_string[64];
-  xml_fill_in_time(time_string, timep, microseconds, XML_LONG_TIME);
+  xml_fill_in_time(time_string, timep, XML_LONG_TIME);
   if (time_string[0]) {
     gbfprintf(ofd, "<%s>%s</%s>\n",
               elname,
index 77ad6c0d3f03e583afd00a8f561865b92e24e6eb..f299ba5137d949ae7180710f929103696559a301 100644 (file)
@@ -52,8 +52,7 @@ void write_xml_entity_end(gbfile* ofd, const QString& indent, const QString& tag
 void write_optional_xml_entity(gbfile* ofd, const QString& indent,
                                const QString& tag, const QString& value);
 void xml_write_time(gbfile* ofd, const time_t timep, int microseconds, const char* elname);
-void xml_fill_in_time(char* time_string, const time_t timep, int microseconds,
-                      int long_or_short);
+void xml_fill_in_time(char* time_string, const time_t timep, int long_or_short);
 void write_xml_header(gbfile* ofd);
 void xml_ignore_tags(const char** taglist);
 
index 0f258f39a63f09438dbd22cff74cd88b725adf05..59efe39fcb7fe4c7ec3ae55c5824c9eb58f050e4 100644 (file)
@@ -199,11 +199,9 @@ xol_fatal_outside(const waypoint *wpt)
 static void
 xol_write_time(const waypoint *wpt)
 {
-  char time_string[64];
-
-  xml_fill_in_time(time_string, wpt->creation_time, wpt->microseconds, XML_LONG_TIME);
-  if (time_string[0]) {
-    gbfprintf(fout, " timestamp=\"%s\"", time_string);
+  QString time_string = wpt->CreationTimeXML();
+  if (!time_string.isEmpty()) {
+    gbfprintf(fout, " timestamp=\"%s\"", qPrintable(time_string));
   }
 }